Fixed false positive stlIfStrFind for function call inside condition.

Removed unnecessary suppressions in .travis_suppressions
This commit is contained in:
PKEuS 2015-11-20 20:08:35 +01:00
parent 8fd62e0cf9
commit 12af125fd3
3 changed files with 10 additions and 5 deletions

View File

@ -7,9 +7,6 @@ uselessAssignmentPtrArg:build/tokenize.cpp
*:test/test.cxx
*:test/cfg*
*:democlient*
*:externals*
*:htdocs*
*:htmlreport*
*:samples*
*:win_installer*

View File

@ -655,11 +655,14 @@ void CheckStl::if_find()
if ((i->type != Scope::eIf && i->type != Scope::eWhile) || !i->classDef)
continue;
for (const Token *tok = i->classDef; tok->str() != "{"; tok = tok->next()) {
for (const Token *tok = i->classDef->next(); tok->str() != "{"; tok = tok->next()) {
const Token* funcTok = nullptr;
const Library::Container* container = nullptr;
if (tok->variable() && Token::Match(tok, "%var% . %name% (")) {
if (Token::Match(tok, "%name% ("))
tok = tok->linkAt(1);
else if (tok->variable() && Token::Match(tok, "%var% . %name% (")) {
container = _settings->library.detectContainer(tok->variable()->typeStartToken());
funcTok = tok->tokAt(2);
}

View File

@ -1721,6 +1721,11 @@ private:
" if (a.find(\"<\") < b.find(\">\")) {}\n"
"}");
ASSERT_EQUALS("", errout.str());
check("void f(const std::string &s) {\n"
" if (foo(s.find(\"abc\"))) { }\n"
"}");
ASSERT_EQUALS("", errout.str());
}