Skip to content

Commit b2fa1ef

Browse files
committed
Refs #12847: fix hang in setVarIdPass1()
1 parent 3c772a4 commit b2fa1ef

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

lib/tokenize.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4508,6 +4508,15 @@ void Tokenizer::setVarId()
45084508
for (Token *tok = list.front(); tok; tok = tok->next()) {
45094509
if (tok->isName())
45104510
tok->varId(0);
4511+
// commas in init..
4512+
if (!Token::Match(tok, "%name%|= {"))
4513+
continue;
4514+
for (Token* tok2 = tok->tokAt(2); tok2 != tok->link(); tok2 = tok2->next()) {
4515+
if (tok2->link() && Token::Match(tok2, "[{[(<]"))
4516+
tok2 = tok2->link();
4517+
else if (tok2->str() == ",")
4518+
tok2->isInitComma(true);
4519+
}
45114520
}
45124521

45134522
setVarIdPass1();
@@ -4838,7 +4847,7 @@ void Tokenizer::setVarIdPass1()
48384847
}
48394848

48404849
// function declaration inside executable scope? Function declaration is of form: type name "(" args ")"
4841-
if (scopeStack.top().isExecutable && Token::Match(tok, "%name% [,)[]")) {
4850+
if (scopeStack.top().isExecutable && Token::Match(tok, "%name% [,)[]") && !tok->next()->isInitComma()) {
48424851
bool par = false;
48434852
const Token* start;
48444853
Token* end;

lib/valueflow.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8626,18 +8626,6 @@ void ValueFlow::setValues(TokenList& tokenlist,
86268626
for (Token* tok = tokenlist.front(); tok; tok = tok->next())
86278627
tok->clearValueFlow();
86288628

8629-
// commas in init..
8630-
for (Token* tok = tokenlist.front(); tok; tok = tok->next()) {
8631-
if (tok->str() != "{" || !tok->astOperand1())
8632-
continue;
8633-
for (Token* tok2 = tok->next(); tok2 != tok->link(); tok2 = tok2->next()) {
8634-
if (tok2->link() && Token::Match(tok2, "[{[(<]"))
8635-
tok2 = tok2->link();
8636-
else if (tok2->str() == ",")
8637-
tok2->isInitComma(true);
8638-
}
8639-
}
8640-
86418629
ValueFlowPassRunner runner{ValueFlowState{tokenlist, symboldatabase, errorLogger, settings}, timerResults};
86428630
runner.run_once({
86438631
VFA(analyzeEnumValue(symboldatabase, settings)),

0 commit comments

Comments
 (0)