Fixed #8194 (False positive reademptycontainer - range based loop)
This commit is contained in:
parent
30f04a5a96
commit
1ecefa045a
|
@ -1601,7 +1601,7 @@ void CheckStl::readingEmptyStlContainer()
|
|||
if (var && !var->isArrayOrPointer() && !var->typeStartToken()->isStandardType()) {
|
||||
bool insert = false;
|
||||
if (var->nameToken() == tok && var->isLocal() && !var->isStatic()) { // Local variable declared
|
||||
insert = !Token::Match(tok->next(), "[(=]"); // Only if not initialized
|
||||
insert = !Token::Match(tok->next(), "[(=:]"); // Only if not initialized
|
||||
} else if (Token::Match(tok, "%var% . clear ( ) ;")) {
|
||||
insert = true;
|
||||
}
|
||||
|
|
|
@ -3059,6 +3059,13 @@ private:
|
|||
" l();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(const std::vector<std::string> &v) {\n"
|
||||
" for (const std::string& s : v) {\n"
|
||||
" if (s.find(x) != string::npos) {}\n"
|
||||
" }\n"
|
||||
"}", true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue