| 918 | } |
| 919 | |
| 920 | static 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 | |
| 961 | namespace { |
| 962 | struct InvalidContainerAnalyzer { |