Skip to content

Commit

Permalink
Refs #12847: fix hang in setVarIdPass1()
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jun 15, 2024
1 parent 3c772a4 commit b2fa1ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
11 changes: 10 additions & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4508,6 +4508,15 @@ void Tokenizer::setVarId()
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->isName())
tok->varId(0);
// commas in init..
if (!Token::Match(tok, "%name%|= {"))
continue;
for (Token* tok2 = tok->tokAt(2); tok2 != tok->link(); tok2 = tok2->next()) {
if (tok2->link() && Token::Match(tok2, "[{[(<]"))
tok2 = tok2->link();
else if (tok2->str() == ",")
tok2->isInitComma(true);
}
}

setVarIdPass1();
Expand Down Expand Up @@ -4838,7 +4847,7 @@ void Tokenizer::setVarIdPass1()
}

// function declaration inside executable scope? Function declaration is of form: type name "(" args ")"
if (scopeStack.top().isExecutable && Token::Match(tok, "%name% [,)[]")) {
if (scopeStack.top().isExecutable && Token::Match(tok, "%name% [,)[]") && !tok->next()->isInitComma()) {
bool par = false;
const Token* start;
Token* end;
Expand Down
12 changes: 0 additions & 12 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8626,18 +8626,6 @@ void ValueFlow::setValues(TokenList& tokenlist,
for (Token* tok = tokenlist.front(); tok; tok = tok->next())
tok->clearValueFlow();

// commas in init..
for (Token* tok = tokenlist.front(); tok; tok = tok->next()) {
if (tok->str() != "{" || !tok->astOperand1())
continue;
for (Token* tok2 = tok->next(); tok2 != tok->link(); tok2 = tok2->next()) {
if (tok2->link() && Token::Match(tok2, "[{[(<]"))
tok2 = tok2->link();
else if (tok2->str() == ",")
tok2->isInitComma(true);
}
}

ValueFlowPassRunner runner{ValueFlowState{tokenlist, symboldatabase, errorLogger, settings}, timerResults};
runner.run_once({
VFA(analyzeEnumValue(symboldatabase, settings)),
Expand Down

0 comments on commit b2fa1ef

Please sign in to comment.