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

Method getContainerFromAction

lib/library.cpp:1925–1946  ·  view source on GitHub ↗

cppcheck-suppress unusedFunction

Source from the content-addressed store, hash-verified

1923
1924// cppcheck-suppress unusedFunction
1925const Token* Library::getContainerFromAction(const Token* tok, Library::Container::Action action) const
1926{
1927 if (!tok)
1928 return nullptr;
1929 if (Token::Match(tok->tokAt(-2), ". %name% (")) {
1930 const Token* containerTok = tok->tokAt(-2)->astOperand1();
1931 if (!astIsContainer(containerTok))
1932 return nullptr;
1933 if (containerTok->valueType()->container &&
1934 containerTok->valueType()->container->getAction(tok->strAt(-1)) == action)
1935 return containerTok;
1936 if (Token::simpleMatch(tok->tokAt(-1), "empty ( )"))
1937 return containerTok;
1938 } else if (Token::Match(tok->previous(), "%name% (")) {
1939 if (const Library::Function* f = this->getFunction(tok->previous())) {
1940 if (f->containerAction == action) {
1941 return tok->astOperand2();
1942 }
1943 }
1944 }
1945 return nullptr;
1946}
1947
1948const std::unordered_map<std::string, Library::SmartPointer>& Library::smartPointers() const
1949{

Callers

nothing calls this directly

Calls 7

getFunctionMethod · 0.95
astIsContainerFunction · 0.85
astOperand1Method · 0.80
getActionMethod · 0.80
astOperand2Method · 0.80
simpleMatchFunction · 0.70
tokAtMethod · 0.45

Tested by

no test coverage detected