Fix 10723: Assertion 'tok && tok->exprId() > 0 && "Missing expr id for symbolic value"' in valueFlowSmartPointer() (#3755)

* Fix 10723:  Assertion 'tok && tok->exprId() > 0 && "Missing expr id for symbolic value"' in valueFlowSmartPointer()

* Format
This commit is contained in:
Paul Fultz II 2022-01-25 23:28:13 -06:00 committed by GitHub
parent c132235a76
commit 1a949c00b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View File

@ -717,6 +717,9 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
// syntax error?
if (!scope)
mTokenizer->syntaxError(tok);
// End of scope or list should be handled above
if (tok->str() == "}")
mTokenizer->syntaxError(tok);
}
}
}
@ -3046,11 +3049,9 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok)
// find start of function '{'
bool foundInitList = false;
while (tok1 && tok1->str() != "{" && tok1->str() != ";") {
if (tok1->link() && Token::Match(tok1, "(|<")) {
if (tok1->link() && Token::Match(tok1, "(|[|<")) {
tok1 = tok1->link();
} else if (foundInitList &&
Token::Match(tok1, "%name%|> {") &&
Token::Match(tok1->linkAt(1), "} ,|{")) {
} else if (foundInitList && Token::Match(tok1, "%name%|> {") && Token::Match(tok1->linkAt(1), "} ,|{")) {
tok1 = tok1->linkAt(1);
} else {
if (tok1->str() == ":")

View File

@ -6226,6 +6226,21 @@ private:
" }\n"
"};\n";
valueOfTok(code, "e");
code = "struct a {\n"
" struct b {\n"
" std::unique_ptr<a> c;\n"
" };\n"
" void d(int, void *);\n"
" void e() {\n"
" d(0, [f = b{}] { return f.c.get(); }());\n"
" }\n"
" void g() {\n"
" if (b *h = 0)\n"
" h->c.get();\n"
" }\n"
"};\n";
valueOfTok(code, "f.c");
}
void valueFlowHang() {