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

Function getParentLifetime

lib/astutils.cpp:619–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

617}
618
619const Token* getParentLifetime(const Token* tok)
620{
621 if (!tok)
622 return tok;
623 // Skipping checking for variable if its a pointer-to-member
624 if (!Token::simpleMatch(tok->previous(), ". *")) {
625 const Variable* var = tok->variable();
626 // TODO: Call getLifetimeVariable for deeper analysis
627 if (!var)
628 return tok;
629 if (var->isLocal() || var->isArgument())
630 return tok;
631 }
632 const Token* parent = getParentMember(tok);
633 if (parent != tok)
634 return getParentLifetime(parent);
635 return tok;
636}
637
638static std::vector<const Token*> getParentMembers(const Token* tok)
639{

Callers 4

valueFlowForwardLifetimeFunction · 0.85
checkConstVariableMethod · 0.85
checkComparePointersMethod · 0.85
checkVarLifetimeScopeMethod · 0.85

Calls 15

getParentMemberFunction · 0.85
getParentMembersFunction · 0.85
isTemporaryFunction · 0.85
getParentLifetimeObjectFunction · 0.85
astIsPointerFunction · 0.85
astIsContainerViewFunction · 0.85
astIsIteratorFunction · 0.85
astIsUniqueSmartPointerFunction · 0.85
astIsSmartPointerFunction · 0.85
variableMethod · 0.80
isArrayMethod · 0.80

Tested by

no test coverage detected