36 logChecker(
"CheckBoost::checkBoostForeachModification");
49 for (; tok2 != end; tok2 = tok2->
next()) {
50 if (
Token::Match(tok2,
"%varid% . insert|erase|push_back|push_front|pop_front|pop_back|clear|swap|resize|assign|merge|remove|remove_if|reverse|sort|splice|unique|pop|push", containerTok->
varId())) {
52 if (!
Token::Match(nextStatement,
"; break|return|throw"))
64 "BOOST_FOREACH caches the end() iterator. It's undefined behavior if you modify the container inside.",
CWE664,
Certainty::normal
static const CWE CWE664(664)
void checkBoostForeachModification()
Check for container modification while using the BOOST_FOREACH macro
void boostForeachError(const Token *tok)
void reportError(const Token *tok, const Severity severity, const std::string &id, const std::string &msg)
report an error
const Tokenizer *const mTokenizer
void logChecker(const char id[])
log checker
const Token * bodyStart
'{' token
const Token * bodyEnd
'}' token
std::vector< const Scope * > functionScopes
Fast access to function scopes.
The token list that the TokenList generates is a linked-list of this class.
static bool Match(const Token *tok, const char pattern[], nonneg int varid=0)
Match given token (or list of tokens) to a pattern list.
static const Token * findsimplematch(const Token *const startTok, const char(&pattern)[count])
const Token * tokAt(int index) const
void link(Token *linkToToken)
Create link to given token.
const Token * linkAt(int index) const
static bool simpleMatch(const Token *tok, const char(&pattern)[count])
Match given token (or list of tokens) to a pattern list.
const SymbolDatabase * getSymbolDatabase() const
@ error
Programming error.