Fix issue 9907: False positive: knownEmptyContainer after function call with :: (#2814)

This commit is contained in:
Paul Fultz II 2020-09-20 15:37:28 -05:00 committed by GitHub
parent 730b95331e
commit 7b6d3f8061
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -1388,6 +1388,11 @@ const Token * getTokenArgumentFunction(const Token * tok, int& argn)
while (Token::simpleMatch(tok, "."))
tok = tok->astOperand2();
while (Token::simpleMatch(tok, "::")) {
// If there is only a op1 and not op2, then this is a global scope
if (!tok->astOperand2() && tok->astOperand1()) {
tok = tok->astOperand1();
break;
}
tok = tok->astOperand2();
if (Token::simpleMatch(tok, "<") && tok->link())
tok = tok->astOperand1();

View File

@ -4713,6 +4713,20 @@ private:
"}\n",
true);
ASSERT_EQUALS("", errout.str());
check("static void f1(std::list<std::string>& parameters) {\n"
" parameters.push_back(a);\n"
"}\n"
"int f2(std::list<std::string>& parameters) {\n"
" f1(parameters);\n"
"}\n"
"void f3() {\n"
" std::list<std::string> parameters;\n"
" int res = ::f2(parameters);\n"
" for (auto param : parameters) {}\n"
"}\n",
true);
ASSERT_EQUALS("", errout.str());
}
void checkMutexes() {