Fixed #8360 (false positive "Ineffective call of function 'empty()'")
This commit is contained in:
parent
7e2858f158
commit
b398398dec
|
@ -1429,6 +1429,7 @@ void CheckStl::uselessCalls()
|
|||
} else if (Token::simpleMatch(tok->linkAt(3)->tokAt(-2), ", 0 )"))
|
||||
uselessCallsSubstrError(tok, true);
|
||||
} else if (printWarning && Token::Match(tok, "[{};] %var% . empty ( ) ;") &&
|
||||
!tok->tokAt(4)->astParent() &&
|
||||
tok->next()->variable() && tok->next()->variable()->isStlType(stl_containers_with_empty_and_clear))
|
||||
uselessCallsEmptyError(tok->next());
|
||||
else if (Token::Match(tok, "[{};] std :: remove|remove_if|unique (") && tok->tokAt(5)->nextArgument())
|
||||
|
|
|
@ -2766,6 +2766,12 @@ private:
|
|||
" return x ? true : (y.empty());\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #8360
|
||||
check("void f(std::string s) {\n"
|
||||
" for (;s.empty();) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void stabilityOfChecks() {
|
||||
|
|
Loading…
Reference in New Issue