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

Function getAddressContainer

lib/checkstl.cpp:677–692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

675}
676
677static std::vector<const Token*> getAddressContainer(const Token* tok)
678{
679 if (Token::simpleMatch(tok, "[") && tok->astOperand1())
680 return { tok->astOperand1() };
681 while (Token::simpleMatch(tok, "::") && tok->astOperand2())
682 tok = tok->astOperand2();
683 std::vector<ValueFlow::Value> values = ValueFlow::getLifetimeObjValues(tok, /*inconclusive*/ false);
684 std::vector<const Token*> res;
685 for (const auto& v : values) {
686 if (v.tokvalue)
687 res.emplace_back(v.tokvalue);
688 }
689 if (res.empty())
690 res.emplace_back(tok);
691 return res;
692}
693
694static bool isSameIteratorContainerExpression(const Token* tok1,
695 const Token* tok2,

Callers 1

Calls 4

astOperand1Method · 0.80
astOperand2Method · 0.80
simpleMatchFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected