#7218 Improve performance in TokenList::validateAst(): Keep a list of 'verified' tokens during recursion check.
This commit is contained in:
parent
2ceb93b2a1
commit
28a625abd8
|
@ -1061,6 +1061,7 @@ void TokenList::createAst()
|
||||||
|
|
||||||
void TokenList::validateAst()
|
void TokenList::validateAst()
|
||||||
{
|
{
|
||||||
|
std::set < const Token* > astTokens;
|
||||||
// Verify that ast looks ok
|
// Verify that ast looks ok
|
||||||
for (const Token *tok = _front; tok; tok = tok->next()) {
|
for (const Token *tok = _front; tok; tok = tok->next()) {
|
||||||
// Syntax error if binary operator only has 1 operand
|
// Syntax error if binary operator only has 1 operand
|
||||||
|
@ -1076,6 +1077,10 @@ void TokenList::validateAst()
|
||||||
while ((parent = parent->astParent()) != nullptr) {
|
while ((parent = parent->astParent()) != nullptr) {
|
||||||
if (parent==tok)
|
if (parent==tok)
|
||||||
throw InternalError(tok, "AST broken: endless recursion from '" + tok->str() + "'", InternalError::SYNTAX);
|
throw InternalError(tok, "AST broken: endless recursion from '" + tok->str() + "'", InternalError::SYNTAX);
|
||||||
|
if (astTokens.find(parent)!= astTokens.end()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
astTokens.insert(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue