diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index fa8dd86b0..05b89ed61 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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(), "++|--")) { diff --git a/test/testvarid.cpp b/test/testvarid.cpp index f9140fa42..f54f25cca 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -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 g(int i) { return std::make_unique(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() {