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

Method invalidContainerLoopError

lib/checkstl.cpp:1234–1247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1232}
1233
1234void CheckStlImpl::invalidContainerLoopError(const Token* tok, const Token* loopTok, ErrorPath errorPath)
1235{
1236 const std::string method = tok ? tok->str() : "erase";
1237 errorPath.emplace_back(loopTok, "Iterating container here.");
1238
1239 // Remove duplicate entries from error path
1240 errorPath.remove_if([&](const ErrorPathItem& epi) {
1241 return epi.first == tok;
1242 });
1243
1244 const std::string msg = "Calling '" + method + "' while iterating the container is invalid.";
1245 errorPath.emplace_back(tok, "");
1246 reportError(std::move(errorPath), Severity::error, "invalidContainerLoop", msg, CWE664, Certainty::normal);
1247}
1248
1249void CheckStlImpl::invalidContainerError(const Token *tok, const ValueFlow::Value *val, ErrorPath errorPath)
1250{

Callers 1

getErrorMessagesMethod · 0.80

Calls 2

reportErrorFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected