Fix 10931: Assert failure in setSymbolic() (#3967)

* Fix 10931: Assert failure in setSymbolic()

* Format
This commit is contained in:
Paul Fultz II 2022-04-03 13:04:18 -05:00 committed by GitHub
parent 0547cbcd26
commit 39265f8ce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -1466,6 +1466,9 @@ void SymbolDatabase::createSymbolDatabaseEscapeFunctions()
static bool isExpression(const Token* tok)
{
if (Token::simpleMatch(tok, "{") && tok->scope() && tok->scope()->bodyStart != tok &&
(tok->astOperand1() || tok->astOperand2()))
return true;
if (!Token::Match(tok, "(|.|[|::|?|:|++|--|%cop%|%assign%"))
return false;
if (Token::Match(tok, "*|&|&&")) {

View File

@ -3203,7 +3203,8 @@ private:
"A f() {\n"
" return A{0};\n"
"}\n");
TODO_ASSERT_EQUALS("error", "", errout.str());
ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:8]: (error) Returning object that will be invalid when returning.\n",
errout.str());
check("struct A {\n"
" int n;\n"

View File

@ -6428,6 +6428,12 @@ private:
" return x;\n"
"}\n";
valueOfTok(code, "x");
code = "int* g();\n"
"void f() {\n"
" std::cout << (void*)(std::shared_ptr<int>{ g() }.get());\n"
"}\n";
valueOfTok(code, ".");
}
void valueFlowHang() {