#7218 Improve performance in TokenList::validateAst(): Keep a list of 'verified' tokens during recursion check.

This commit is contained in:
Alexander Mai 2015-12-19 20:36:30 +01:00
parent 2ceb93b2a1
commit 28a625abd8
1 changed files with 5 additions and 0 deletions

View File

@ -1061,6 +1061,7 @@ void TokenList::createAst()
void TokenList::validateAst()
{
std::set < const Token* > astTokens;
// Verify that ast looks ok
for (const Token *tok = _front; tok; tok = tok->next()) {
// Syntax error if binary operator only has 1 operand
@ -1076,6 +1077,10 @@ void TokenList::validateAst()
while ((parent = parent->astParent()) != nullptr) {
if (parent==tok)
throw InternalError(tok, "AST broken: endless recursion from '" + tok->str() + "'", InternalError::SYNTAX);
if (astTokens.find(parent)!= astTokens.end()) {
break;
}
astTokens.insert(parent);
}
}
}