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

Function isMapFind

lib/checkstl.cpp:1608–1627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1606}
1607
1608static std::pair<const Token *, const Token *> isMapFind(const Token *tok)
1609{
1610 if (!Token::simpleMatch(tok, "("))
1611 return {};
1612 if (!Token::simpleMatch(tok->astOperand1(), "."))
1613 return {};
1614 if (!astIsContainer(tok->astOperand1()->astOperand1()))
1615 return {};
1616 const Token * contTok = tok->astOperand1()->astOperand1();
1617 const Library::Container * container = contTok->valueType()->container;
1618 if (!container)
1619 return {};
1620 if (!container->stdAssociativeLike)
1621 return {};
1622 if (!Token::Match(tok->astOperand1(), ". find|count ("))
1623 return {};
1624 if (!tok->astOperand2())
1625 return {};
1626 return {contTok, tok->astOperand2()};
1627}
1628
1629static const Token* skipLocalVars(const Token* const tok)
1630{

Callers 1

checkFindInsertMethod · 0.85

Calls 4

astIsContainerFunction · 0.85
astOperand1Method · 0.80
astOperand2Method · 0.80
simpleMatchFunction · 0.70

Tested by

no test coverage detected