File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1588,7 +1588,7 @@ namespace {
15881588 if (op1 && op1->exprId () == 0 )
15891589 return ;
15901590 const Token* op2 = tok->astParent ()->astOperand2 ();
1591- if (op2 && op2->exprId () == 0 )
1591+ if (op2 && op2->exprId () == 0 && !( isLambdaCaptureList (op2) || (op2-> str () == " ( " && isLambdaCaptureList (op2-> astOperand1 ()))) )
15921592 return ;
15931593
15941594 if (tok->astParent ()->isExpandedMacro () || Token::Match (tok->astParent (), " ++|--" )) {
Original file line number Diff line number Diff line change @@ -3968,6 +3968,18 @@ class TestVarID : public TestFixture {
39683968 " 3: ( ( s@1 +=@UNIQUE \" --\" @UNIQUE ) +=@UNIQUE std ::@UNIQUE string (@UNIQUE ) ) +=@UNIQUE \" =\" @UNIQUE ;\n "
39693969 " 4: }\n " ;
39703970 ASSERT_EQUALS (expected, tokenizeExpr (code));
3971+
3972+ const char code2[] = " struct S { std::function<void()>* p; };\n "
3973+ " S f() { return S{ std::make_unique<std::function<void()>>([]() {}).release()}; }" ;
3974+ const char expected2[] = " 1: struct S { std :: function < void ( ) > * p ; } ;\n "
3975+ " 2: S f ( ) { return S@UNIQUE {@UNIQUE std ::@UNIQUE make_unique < std :: function < void ( ) > > (@UNIQUE [ ] ( ) { } ) .@UNIQUE release (@UNIQUE ) } ; }\n " ;
3976+ ASSERT_EQUALS (expected2, tokenizeExpr (code2));
3977+
3978+ const char code3[] = " struct S { int* p; };\n "
3979+ " S f() { return S{ std::make_unique<int>([]() { return 4; }()).release()}; }\n " ;
3980+ const char expected3[] = " 1: struct S { int * p ; } ;\n "
3981+ " 2: S f ( ) { return S@UNIQUE {@UNIQUE std ::@UNIQUE make_unique < int > (@UNIQUE [ ] ( ) { return 4 ; } ( ) ) .@UNIQUE release (@UNIQUE ) } ; }\n " ;
3982+ ASSERT_EQUALS (expected3, tokenizeExpr (code3));
39713983 }
39723984
39733985 void structuredBindings () {
You can’t perform that action at this time.
0 commit comments