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

Method isContainerSizeChanged

lib/valueflow.cpp:6233–6270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6231}
6232
6233bool ValueFlow::isContainerSizeChanged(const Token* tok, int indirect, const Settings& settings, int depth)
6234{
6235 if (!tok)
6236 return false;
6237 if (!tok->valueType() || !tok->valueType()->container)
6238 return true;
6239 if (astIsLHS(tok) && Token::Match(tok->astParent(), "%assign%|<<"))
6240 return true;
6241 if (astIsLHS(tok) && Token::simpleMatch(tok->astParent(), "["))
6242 return tok->valueType()->container->stdAssociativeLike;
6243 if (Token::simpleMatch(tok->astParent(), "*") && indirect > 0)
6244 return isContainerSizeChanged(tok->astParent(), indirect - 1, settings, depth + 1);
6245 const Library::Container::Action action = astContainerAction(tok, settings.library);
6246 switch (action) {
6247 case Library::Container::Action::RESIZE:
6248 case Library::Container::Action::CLEAR:
6249 case Library::Container::Action::PUSH:
6250 case Library::Container::Action::POP:
6251 case Library::Container::Action::CHANGE:
6252 case Library::Container::Action::INSERT:
6253 case Library::Container::Action::ERASE:
6254 case Library::Container::Action::APPEND:
6255 return true;
6256 case Library::Container::Action::NO_ACTION:
6257 // Is this an unknown member function call?
6258 if (astIsLHS(tok) && Token::Match(tok->astParent(), ". %name% (")) {
6259 const Library::Container::Yield yield = astContainerYield(tok, settings.library);
6260 return yield == Library::Container::Yield::NO_YIELD;
6261 }
6262 break;
6263 case Library::Container::Action::FIND:
6264 case Library::Container::Action::FIND_CONST:
6265 case Library::Container::Action::CHANGE_CONTENT:
6266 case Library::Container::Action::CHANGE_INTERNAL:
6267 break;
6268 }
6269 return isContainerSizeChangedByFunction(tok, indirect, settings, depth);
6270}
6271
6272static bool isContainerSizeChanged(const Token* expr,
6273 const Token* start,

Callers

nothing calls this directly

Calls 7

astIsLHSFunction · 0.85
isContainerSizeChangedFunction · 0.85
astContainerActionFunction · 0.85
astContainerYieldFunction · 0.85
astParentMethod · 0.80
simpleMatchFunction · 0.70

Tested by

no test coverage detected