Fixed #6887 (False positive eraseDereference - container is member of member variable)
This commit is contained in:
parent
594d30f7ae
commit
9085fdc156
|
@ -395,7 +395,9 @@ void CheckStl::eraseCheckLoopVar(const Scope &scope, const Variable *var)
|
|||
for (const Token *tok = scope.classStart; tok != scope.classEnd; tok = tok->next()) {
|
||||
if (tok->str() != "(")
|
||||
continue;
|
||||
if (!Token::Match(tok->tokAt(-4), "!!= %name% . erase ( ++| %varid% )", var->declarationId()))
|
||||
if (!Token::Match(tok->tokAt(-2), ". erase ( ++| %varid% )", var->declarationId()))
|
||||
continue;
|
||||
if (Token::simpleMatch(tok->astParent(), "="))
|
||||
continue;
|
||||
// Iterator is invalid..
|
||||
unsigned int indentlevel = 0U;
|
||||
|
|
|
@ -674,6 +674,14 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" std::list<int>::iterator i;\n"
|
||||
" while (i != x.y.end())\n"
|
||||
" i = x.y.erase(i);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #2101
|
||||
check("void f(vector< list<int> > &ints, unsigned int i)\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue