Skip to content

Commit e61ca25

Browse files
Fix #12571 debug: valueFlowBailoutIncompleteVar with trailing return type (#6229)
1 parent 35a7eb9 commit e61ca25

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

lib/symboldatabase.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,9 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars()
15541554
parent = parent->astParent();
15551555
if (Token::simpleMatch(parent, "new"))
15561556
continue;
1557+
// trailing return type
1558+
if (Token::simpleMatch(ftok, ".") && ftok->originalName() == "->" && Token::Match(ftok->tokAt(-1), "[])]"))
1559+
continue;
15571560
}
15581561
tok->isIncompleteVar(true);
15591562
}

test/testsymboldatabase.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5845,6 +5845,16 @@ class TestSymbolDatabase : public TestFixture {
58455845
const Token* r = Token::findsimplematch(q, "r");
58465846
ASSERT(r && !r->isIncompleteVar());
58475847
}
5848+
{
5849+
GET_SYMBOL_DB("void f() {\n" // #12571
5850+
" auto g = []() -> std::string* {\n"
5851+
" return nullptr;\n"
5852+
" };\n"
5853+
"}\n");
5854+
ASSERT(db && errout_str().empty());
5855+
const Token* s = Token::findsimplematch(tokenizer.tokens(), "string");
5856+
ASSERT(s && !s->isIncompleteVar());
5857+
}
58485858
}
58495859

58505860
void enum1() {

0 commit comments

Comments
 (0)