diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 0d3da681fcd3..43b9bfa4361f 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1717,6 +1717,10 @@ void SymbolDatabase::createSymbolDatabaseExprIds() setParentExprId(tok, exprIdMap, id); } } + for (Token* tok = const_cast(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { + if (tok->varId() == 0 && tok->astParent() && !tok->astOperand1() && !tok->astOperand2()) + tok->exprId(0); + } } // Mark expressions that are unique diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 786e1cf901b8..860133af1ada 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -3879,9 +3879,9 @@ class TestVarID : public TestFixture { const char expected[] = "1: struct S { std :: unique_ptr < int > u ; } ;\n" "2: auto f ; f = [ ] ( const S & s ) . std :: unique_ptr < int > {\n" - "3: if ( auto p@4 =@UNIQUE10 s@3 .@UNIQUE6 u@5 .@UNIQUE8 get@UNIQUE7 (@UNIQUE9 ) ) {\n" - "4: return std@UNIQUE11 ::@UNIQUE13 make_unique@UNIQUE12 < int > (@UNIQUE15 *@UNIQUE14 p@4 ) ; }\n" - "5: return nullptr@UNIQUE16 ;\n" + "3: if ( auto p@4 =@UNIQUE10 s@3 .@UNIQUE6 u@5 .@UNIQUE8 get (@UNIQUE9 ) ) {\n" + "4: return std ::@UNIQUE13 make_unique < int > (@UNIQUE15 *@UNIQUE14 p@4 ) ; }\n" + "5: return nullptr ;\n" "6: } ;\n"; ASSERT_EQUALS(expected, actual); @@ -3893,8 +3893,8 @@ class TestVarID : public TestFixture { " while (b && y > 0) {}\n" "}\n"; const char expected[] = "1: void f ( bool b , int y ) {\n" - "2: if ( b@1 &&@5 y@2 >@4 0@3 ) { }\n" - "3: while ( b@1 &&@5 y@2 >@4 0@3 ) { }\n" + "2: if ( b@1 &&@5 y@2 >@4 0 ) { }\n" + "3: while ( b@1 &&@5 y@2 >@4 0 ) { }\n" "4: }\n"; ASSERT_EQUALS(expected, tokenizeExpr(code)); }