Fixed #9571 (False positive: containerSize)

This commit is contained in:
Daniel Marjamäki 2020-02-12 18:53:36 +01:00
parent 3675f49a53
commit 3ec03b8915
2 changed files with 8 additions and 1 deletions

View File

@ -5772,7 +5772,7 @@ static void valueFlowContainerSize(TokenList *tokenlist, SymbolDatabase* symbold
{
// declaration
for (const Variable *var : symboldatabase->variableList()) {
if (!var || !var->isLocal() || var->isPointer() || var->isReference())
if (!var || !var->isLocal() || var->isPointer() || var->isReference() || var->isStatic())
continue;
if (!var->valueType() || !var->valueType()->container)
continue;

View File

@ -4053,6 +4053,13 @@ private:
"}";
ASSERT_EQUALS("", isImpossibleContainerSizeValue(tokenValues(code, "s ["), 5));
code = "void f() {\n"
" static std::string s;\n"
" if (s.size() == 0)\n"
" s = x;\n"
"}";
ASSERT(tokenValues(code, "s . size").empty());
// valueFlowContainerForward, loop
code = "void f() {\n"
" std::stack<Token *> links;\n"