| 1640 | } |
| 1641 | |
| 1642 | static bool isVariableMutableInInitializer(const Token* start, const Token * end, nonneg int varid) |
| 1643 | { |
| 1644 | if (!start) |
| 1645 | return false; |
| 1646 | if (!end) |
| 1647 | return false; |
| 1648 | for (const Token *tok = start; tok != end; tok = tok->next()) { |
| 1649 | if (tok->varId() != varid) |
| 1650 | continue; |
| 1651 | if (tok->astParent()) { |
| 1652 | const Token * memberTok = tok->astParent()->previous(); |
| 1653 | if (Token::Match(memberTok, "%var% (") && memberTok->variable()) { |
| 1654 | const Variable * memberVar = memberTok->variable(); |
| 1655 | if (memberVar->isClass()) |
| 1656 | //TODO: check if the called constructor could live with a const variable |
| 1657 | // pending that, assume the worst (that it can't) |
| 1658 | return true; |
| 1659 | if (!memberVar->isReference()) |
| 1660 | continue; |
| 1661 | if (memberVar->isConst()) |
| 1662 | continue; |
| 1663 | } |
| 1664 | } |
| 1665 | return true; |
| 1666 | } |
| 1667 | return false; |
| 1668 | } |
| 1669 | |
| 1670 | static bool isCastToVoid(const Variable* var) |
| 1671 | { |