Add some debugging code (inspired by #6021)

This commit is contained in:
Alexander Mai 2015-12-27 17:38:15 +01:00
parent f09dded7b1
commit 5b6758b03b
3 changed files with 20 additions and 0 deletions

View File

@ -1274,6 +1274,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
}
}
Token * const tok2 = *iter2;
assert(tokenlist.validateToken(tok2)); // that assertion fails on examples from #6021
if (tok2->str() != name)
continue;

View File

@ -1107,3 +1107,14 @@ std::string TokenList::fileLine(const Token *tok) const
{
return ErrorLogger::ErrorMessage::FileLocation(tok, this).stringify();
}
bool TokenList::validateToken(const Token* tok) const
{
if (!tok)
return true;
for (Token *t = _front; t; t = t->next()) {
if (tok==t)
return true;
}
return false;
}

View File

@ -137,6 +137,14 @@ public:
*/
void validateAst();
/**
* Verify that the given token is an element of the tokenlist.
* That method is implemented for debugging purposes.
* @param[in] tok token to be checked
* \return true if token was found in tokenlist, false else. In case of nullptr true is returned.
*/
bool validateToken(const Token* tok) const;
private:
/** Disable copy constructor, no implementation */