Skip to content

Commit

Permalink
Fix #12258 Assert failure in setSymbolic() (danmar#5759)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Dec 12, 2023
1 parent 2c54f31 commit b26b78b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,8 @@ namespace {
if (op1 && op1->exprId() == 0)
return;
const Token* op2 = tok->astParent()->astOperand2();
if (op2 && op2->exprId() == 0 && !(isLambdaCaptureList(op2) || (op2->str() == "(" && isLambdaCaptureList(op2->astOperand1()))))
if (op2 && op2->exprId() == 0 &&
!(isLambdaCaptureList(op2) || (op2->str() == "(" && isLambdaCaptureList(op2->astOperand1())) || Token::simpleMatch(op2, "{ }")))
return;

if (tok->astParent()->isExpandedMacro() || Token::Match(tok->astParent(), "++|--")) {
Expand Down
12 changes: 12 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3980,6 +3980,18 @@ class TestVarID : public TestFixture {
const char expected3[] = "1: struct S { int * p ; } ;\n"
"2: S f ( ) { return S@UNIQUE {@UNIQUE std ::@UNIQUE make_unique < int > (@UNIQUE [ ] ( ) { return 4 ; } ( ) ) .@UNIQUE release (@UNIQUE ) } ; }\n";
ASSERT_EQUALS(expected3, tokenizeExpr(code3));

const char code4[] = "std::unique_ptr<int> g(int i) { return std::make_unique<int>(i); }\n"
"void h(int*);\n"
"void f() {\n"
" h(g({}).get());\n"
"}\n";
const char expected4[] = "1: std :: unique_ptr < int > g ( int i ) { return std ::@UNIQUE make_unique < int > (@UNIQUE i@1 ) ; }\n"
"2: void h ( int * ) ;\n"
"3: void f ( ) {\n"
"4: h (@UNIQUE g (@UNIQUE { } ) .@UNIQUE get (@UNIQUE ) ) ;\n"
"5: }\n";
ASSERT_EQUALS(expected4, tokenizeExpr(code4));
}

void structuredBindings() {
Expand Down

0 comments on commit b26b78b

Please sign in to comment.