Skip to content

Commit b26b78b

Browse files
Fix #12258 Assert failure in setSymbolic() (#5759)
1 parent 2c54f31 commit b26b78b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/symboldatabase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,8 @@ namespace {
15881588
if (op1 && op1->exprId() == 0)
15891589
return;
15901590
const Token* op2 = tok->astParent()->astOperand2();
1591-
if (op2 && op2->exprId() == 0 && !(isLambdaCaptureList(op2) || (op2->str() == "(" && isLambdaCaptureList(op2->astOperand1()))))
1591+
if (op2 && op2->exprId() == 0 &&
1592+
!(isLambdaCaptureList(op2) || (op2->str() == "(" && isLambdaCaptureList(op2->astOperand1())) || Token::simpleMatch(op2, "{ }")))
15921593
return;
15931594

15941595
if (tok->astParent()->isExpandedMacro() || Token::Match(tok->astParent(), "++|--")) {

test/testvarid.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3980,6 +3980,18 @@ class TestVarID : public TestFixture {
39803980
const char expected3[] = "1: struct S { int * p ; } ;\n"
39813981
"2: S f ( ) { return S@UNIQUE {@UNIQUE std ::@UNIQUE make_unique < int > (@UNIQUE [ ] ( ) { return 4 ; } ( ) ) .@UNIQUE release (@UNIQUE ) } ; }\n";
39823982
ASSERT_EQUALS(expected3, tokenizeExpr(code3));
3983+
3984+
const char code4[] = "std::unique_ptr<int> g(int i) { return std::make_unique<int>(i); }\n"
3985+
"void h(int*);\n"
3986+
"void f() {\n"
3987+
" h(g({}).get());\n"
3988+
"}\n";
3989+
const char expected4[] = "1: std :: unique_ptr < int > g ( int i ) { return std ::@UNIQUE make_unique < int > (@UNIQUE i@1 ) ; }\n"
3990+
"2: void h ( int * ) ;\n"
3991+
"3: void f ( ) {\n"
3992+
"4: h (@UNIQUE g (@UNIQUE { } ) .@UNIQUE get (@UNIQUE ) ) ;\n"
3993+
"5: }\n";
3994+
ASSERT_EQUALS(expected4, tokenizeExpr(code4));
39833995
}
39843996

39853997
void structuredBindings() {

0 commit comments

Comments
 (0)