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

Function isDanglingSubFunction

lib/checkautovariables.cpp:525–542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523}
524
525static bool isDanglingSubFunction(const Token* tokvalue, const Token* tok)
526{
527 if (!tokvalue)
528 return false;
529 const Variable* var = tokvalue->variable();
530 if (!var->isLocal())
531 return false;
532 const Function* f = Scope::nestedInFunction(tok->scope());
533 if (!f)
534 return false;
535 const Token* parent = tokvalue->astParent();
536 while (parent && !Token::Match(parent->previous(), "%name% (")) {
537 parent = parent->astParent();
538 }
539 if (!Token::simpleMatch(parent, "("))
540 return false;
541 return exprDependsOnThis(parent);
542}
543
544static const Variable* getParentVar(const Token* tok)
545{

Callers 1

checkVarLifetimeScopeMethod · 0.85

Calls 6

nestedInFunctionFunction · 0.85
exprDependsOnThisFunction · 0.85
variableMethod · 0.80
scopeMethod · 0.80
astParentMethod · 0.80
simpleMatchFunction · 0.70

Tested by

no test coverage detected