Skip to content

Commit 503a3de

Browse files
committed
better reset of exprid
1 parent 7e1859a commit 503a3de

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

lib/symboldatabase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,8 @@ void SymbolDatabase::createSymbolDatabaseExprIds()
17351735
}
17361736
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
17371737
if (tok->varId() == 0 && tok->exprId() > 0 && tok->astParent() && !tok->astOperand1() && !tok->astOperand2()) {
1738-
if (Token::Match(tok->astParent(), "%name%|.|::"))
1738+
if (tok->isNumber() || tok->isKeyword() || Token::Match(tok->astParent(), ".|::") ||
1739+
(Token::simpleMatch(tok->astParent(), "(") && precedes(tok, tok->astParent())))
17391740
tok->exprId(0);
17401741
}
17411742
}

test/testvarid.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3898,8 +3898,8 @@ class TestVarID : public TestFixture {
38983898
" while (b && y > 0) {}\n"
38993899
"}\n";
39003900
const char expected[] = "1: void f ( bool b , int y ) {\n"
3901-
"2: if ( b@1 &&@5 y@2 >@4 0@3 ) { }\n"
3902-
"3: while ( b@1 &&@5 y@2 >@4 0@3 ) { }\n"
3901+
"2: if ( b@1 &&@5 y@2 >@4 0 ) { }\n"
3902+
"3: while ( b@1 &&@5 y@2 >@4 0 ) { }\n"
39033903
"4: }\n";
39043904
ASSERT_EQUALS(expected, tokenizeExpr(code));
39053905
}

0 commit comments

Comments
 (0)