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

Function getInvalidMethod

lib/checkstl.cpp:920–959  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

918}
919
920static const Token* getInvalidMethod(const Token* tok)
921{
922 if (!astIsLHS(tok))
923 return nullptr;
924 if (Token::Match(tok->astParent(), ". assign|clear|swap"))
925 return tok->astParent()->next();
926 if (Token::Match(tok->astParent(), "%assign%"))
927 return tok->astParent();
928 const Token* ftok = nullptr;
929 if (Token::Match(tok->astParent(), ". %name% ("))
930 ftok = tok->astParent()->next();
931 if (!ftok)
932 return nullptr;
933 if (const Library::Container * c = tok->valueType()->container) {
934 const Library::Container::Action action = c->getAction(ftok->str());
935 if (c->unstableErase) {
936 if (action == Library::Container::Action::ERASE)
937 return ftok;
938 }
939 if (c->unstableInsert) {
940 if (action == Library::Container::Action::RESIZE)
941 return ftok;
942 if (action == Library::Container::Action::CLEAR)
943 return ftok;
944 if (action == Library::Container::Action::PUSH)
945 return ftok;
946 if (action == Library::Container::Action::POP)
947 return ftok;
948 if (action == Library::Container::Action::INSERT)
949 return ftok;
950 if (action == Library::Container::Action::CHANGE)
951 return ftok;
952 if (action == Library::Container::Action::CHANGE_INTERNAL)
953 return ftok;
954 if (Token::Match(ftok, "insert|emplace"))
955 return ftok;
956 }
957 }
958 return nullptr;
959}
960
961namespace {
962 struct InvalidContainerAnalyzer {

Callers 1

invalidatesContainerMethod · 0.85

Calls 5

astIsLHSFunction · 0.85
astParentMethod · 0.80
nextMethod · 0.80
getActionMethod · 0.80
strMethod · 0.45

Tested by

no test coverage detected