Tokenizer: Added a simple validation function that we can use during debugging
This commit is contained in:
parent
62bdf032ac
commit
e3119235e0
|
@ -3913,3 +3913,35 @@ void Tokenizer::simplifyComma()
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Tokenizer::validate() const
|
||||
{
|
||||
std::stack<const Token *> linktok;
|
||||
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next())
|
||||
{
|
||||
if (Token::Match(tok, "[{(]"))
|
||||
{
|
||||
assert(tok->link() != 0);
|
||||
linktok.push(tok);
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (Token::Match(tok, "[})]"))
|
||||
{
|
||||
assert(tok->link() != 0);
|
||||
assert(linktok.empty() == false);
|
||||
assert(tok->link() == linktok.top());
|
||||
assert(tok == tok->link()->link());
|
||||
linktok.pop();
|
||||
continue;
|
||||
}
|
||||
|
||||
assert(tok->link() == 0);
|
||||
}
|
||||
|
||||
assert(linktok.empty());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -305,6 +305,13 @@ private:
|
|||
/** Disable assignments.. */
|
||||
Tokenizer(const Tokenizer &);
|
||||
|
||||
/**
|
||||
* assert that tokens are ok - used during debugging for example
|
||||
* to catch problems in simplifyTokenList.
|
||||
* @return always true.
|
||||
*/
|
||||
bool validate() const;
|
||||
|
||||
/** Disable assignment operator */
|
||||
void operator=(const Tokenizer &);
|
||||
|
||||
|
|
Loading…
Reference in New Issue