Skip to content

Commit

Permalink
do not set exprid for leaves
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Nov 25, 2023
1 parent dcb12fa commit 615c75f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,10 @@ void SymbolDatabase::createSymbolDatabaseExprIds()
setParentExprId(tok, exprIdMap, id);
}
}
for (Token* tok = const_cast<Token*>(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
Expand Down
10 changes: 5 additions & 5 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
}
Expand Down

0 comments on commit 615c75f

Please sign in to comment.