Fixed #7349 (checker 'inefficient find()' unintentionally used for find_first_of())

This commit is contained in:
Daniel Marjamäki 2016-01-29 08:55:46 +01:00
parent 8ef17e70ca
commit fa31ebf88e
2 changed files with 7 additions and 1 deletions

View File

@ -700,7 +700,7 @@ void CheckStl::if_find()
if (printWarning && container->getYield(funcTok->str()) == Library::Container::ITERATOR)
if_findError(tok, false);
else if (printPerformance && container->stdStringLike)
else if (printPerformance && container->stdStringLike && funcTok->str() == "find")
if_findError(tok, true);
} else if (printWarning && Token::Match(tok, "std :: find|find_if (")) {
// check that result is checked properly

View File

@ -1726,6 +1726,12 @@ private:
" if (foo(s.find(\"abc\"))) { }\n"
"}");
ASSERT_EQUALS("", errout.str());
// #7349 - std::string::find_first_of
check("void f(const std::string &s) {\n"
" if (s.find_first_of(\"abc\")==0) { }\n"
"}");
ASSERT_EQUALS("", errout.str());
}