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

Function isParameterChanged

lib/checkcondition.cpp:138–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138static bool isParameterChanged(const Token *partok)
139{
140 bool addressOf = Token::Match(partok, "[(,] &");
141 int argumentNumber = 0;
142 const Token *ftok;
143 for (ftok = partok; ftok && ftok->str() != "("; ftok = ftok->previous()) {
144 if (ftok->str() == ")")
145 ftok = ftok->link();
146 else if (argumentNumber == 0U && ftok->str() == "&")
147 addressOf = true;
148 else if (ftok->str() == ",")
149 argumentNumber++;
150 }
151 ftok = ftok ? ftok->previous() : nullptr;
152 if (!(ftok && ftok->function()))
153 return true;
154 const Variable *par = ftok->function()->getArgumentVar(argumentNumber);
155 if (!par)
156 return true;
157 if (par->isConst())
158 return false;
159 if (addressOf || par->isReference() || par->isPointer())
160 return true;
161 return false;
162}
163
164/** parse scopes recursively */
165bool CheckConditionImpl::assignIfParseScope(const Token * const assignTok,

Callers 2

assignIfParseScopeMethod · 0.85
multiCondition2Method · 0.85

Calls 4

getArgumentVarMethod · 0.80
isConstMethod · 0.80
strMethod · 0.45
functionMethod · 0.45

Tested by

no test coverage detected