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

Function getContainerIndex

lib/checkstl.cpp:104–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104static const Token* getContainerIndex(const Library::Container* container, const Token* parent)
105{
106 if (Token::Match(parent, ". %name% (")) {
107 const Library::Container::Yield yield = container->getYield(parent->strAt(1));
108 if (yield == Library::Container::Yield::AT_INDEX && !Token::simpleMatch(parent->tokAt(2), "( )"))
109 return parent->tokAt(2)->astOperand2();
110 }
111 if (!container->arrayLike_indexOp && !container->stdStringLike)
112 return nullptr;
113 if (Token::simpleMatch(parent, "["))
114 return parent->astOperand2();
115 return nullptr;
116}
117
118static const Token* getContainerFromSize(const Library::Container* container, const Token* tok)
119{

Callers 1

outOfBoundsMethod · 0.85

Calls 4

getYieldMethod · 0.80
astOperand2Method · 0.80
simpleMatchFunction · 0.70
tokAtMethod · 0.45

Tested by

no test coverage detected