Fix #12258 Assert failure in setSymbolic() (#5759)

This commit is contained in:
chrchr-github 2023-12-12 22:37:33 +01:00 committed by GitHub
parent 2c54f31bfe
commit b26b78b86d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -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(), "++|--")) {

View File

@ -3980,6 +3980,18 @@ private:
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() {