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

Function getParentMembers

lib/astutils.cpp:638–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

636}
637
638static std::vector<const Token*> getParentMembers(const Token* tok)
639{
640 if (!tok)
641 return {};
642 if (!Token::simpleMatch(tok->astParent(), "."))
643 return {tok};
644 const Token* parent = tok->astParent();
645 while (Token::simpleMatch(parent->astParent(), "."))
646 parent = parent->astParent();
647 std::vector<const Token*> result;
648 for (const Token* tok2 : astFlatten(parent, ".")) {
649 if (Token::simpleMatch(tok2, "(") && Token::simpleMatch(tok2->astOperand1(), ".")) {
650 std::vector<const Token*> sub = getParentMembers(tok2->astOperand1());
651 result.insert(result.end(), sub.cbegin(), sub.cend());
652 }
653 result.push_back(tok2);
654 }
655 return result;
656}
657
658static const Token* getParentLifetimeObject(const Token* tok)
659{

Callers 1

getParentLifetimeFunction · 0.85

Calls 6

astFlattenFunction · 0.85
astParentMethod · 0.80
astOperand1Method · 0.80
simpleMatchFunction · 0.70
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected