Skip to content

Commit

Permalink
Fix #12571 debug: valueFlowBailoutIncompleteVar with trailing return …
Browse files Browse the repository at this point in the history
…type (#6229)
  • Loading branch information
chrchr-github authored Apr 4, 2024
1 parent 35a7eb9 commit e61ca25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,9 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars()
parent = parent->astParent();
if (Token::simpleMatch(parent, "new"))
continue;
// trailing return type
if (Token::simpleMatch(ftok, ".") && ftok->originalName() == "->" && Token::Match(ftok->tokAt(-1), "[])]"))
continue;
}
tok->isIncompleteVar(true);
}
Expand Down
10 changes: 10 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,16 @@ class TestSymbolDatabase : public TestFixture {
const Token* r = Token::findsimplematch(q, "r");
ASSERT(r && !r->isIncompleteVar());
}
{
GET_SYMBOL_DB("void f() {\n" // #12571
" auto g = []() -> std::string* {\n"
" return nullptr;\n"
" };\n"
"}\n");
ASSERT(db && errout_str().empty());
const Token* s = Token::findsimplematch(tokenizer.tokens(), "string");
ASSERT(s && !s->isIncompleteVar());
}
}

void enum1() {
Expand Down

0 comments on commit e61ca25

Please sign in to comment.