MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / isUnchanged

Function isUnchanged

lib/fwdanalysis.cpp:34–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32#include <utility>
33
34static 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
59static bool hasFunctionCall(const Token *tok)
60{

Callers 1

checkRecursiveMethod · 0.85

Calls 10

nextMethod · 0.80
linkAtMethod · 0.80
astParentMethod · 0.80
isAssignmentOpMethod · 0.80
isUnaryOpMethod · 0.80
astOperand1Method · 0.80
simpleMatchFunction · 0.70
findMethod · 0.45
endMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected