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

Function variableIsUsedInScope

lib/checkautovariables.cpp:188–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188static bool variableIsUsedInScope(const Token* start, nonneg int varId, const Scope *scope)
189{
190 if (!start) // Ticket #5024
191 return false;
192
193 for (const Token *tok = start; tok && tok != scope->bodyEnd; tok = tok->next()) {
194 if (tok->varId() == varId)
195 return true;
196 const ScopeType scopeType = tok->scope()->type;
197 if (scopeType == ScopeType::eFor || scopeType == ScopeType::eDo || scopeType == ScopeType::eWhile) // In case of loops, better checking would be necessary
198 return true;
199 if (Token::simpleMatch(tok, "asm ("))
200 return true;
201 }
202 return false;
203}
204
205void CheckAutoVariablesImpl::assignFunctionArg()
206{

Callers 1

assignFunctionArgMethod · 0.85

Calls 3

nextMethod · 0.80
scopeMethod · 0.80
simpleMatchFunction · 0.70

Tested by

no test coverage detected