Skip to content

Commit

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

if (tok->astParent()->isExpandedMacro() || Token::Match(tok->astParent(), "++|--")) {
Expand Down
6 changes: 6 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3968,6 +3968,12 @@ class TestVarID : public TestFixture {
"3: ( ( s@1 +=@UNIQUE \"--\"@UNIQUE ) +=@UNIQUE std ::@UNIQUE string (@UNIQUE ) ) +=@UNIQUE \"=\"@UNIQUE ;\n"
"4: }\n";
ASSERT_EQUALS(expected, tokenizeExpr(code));

const char code2[] = "struct S { int* p; };\n"
"S f() { return S{ std::make_unique<int>([]() { return 4; }()).release()}; }\n";
const char expected2[] = "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(expected2, tokenizeExpr(code2));
}

void structuredBindings() {
Expand Down

0 comments on commit 4aaa314

Please sign in to comment.