| 32 | #include <utility> |
| 33 | |
| 34 | static bool isUnchanged(const Token *startToken, const Token *endToken, const std::set<nonneg int> &exprVarIds, bool local) |
| 35 | { |
| 36 | for (const Token *tok = startToken; tok != endToken; tok = tok->next()) { |
| 37 | if (!local && Token::Match(tok, "%name% (") && !Token::simpleMatch(tok->linkAt(1), ") {")) |
| 38 | // TODO: this is a quick bailout |
| 39 | return false; |
| 40 | if (tok->varId() == 0 || exprVarIds.find(tok->varId()) == exprVarIds.end()) |
| 41 | continue; |
| 42 | const Token *parent = tok; |
| 43 | while (parent->astParent() && !parent->astParent()->isAssignmentOp() && parent->astParent()->tokType() != Token::Type::eIncDecOp) { |
| 44 | if (parent->str() == "," || parent->isUnaryOp("&")) |
| 45 | // TODO: This is a quick bailout |
| 46 | return false; |
| 47 | parent = parent->astParent(); |
| 48 | } |
| 49 | if (parent->astParent()) { |
| 50 | if (parent->astParent()->tokType() == Token::Type::eIncDecOp) |
| 51 | return false; |
| 52 | if (parent->astParent()->isAssignmentOp() && parent == parent->astParent()->astOperand1()) |
| 53 | return false; |
| 54 | } |
| 55 | } |
| 56 | return true; |
| 57 | } |
| 58 | |
| 59 | static bool hasFunctionCall(const Token *tok) |
| 60 | { |
no test coverage detected