Rewrite Tokenizer::hasEnumsWithTypedef by using 'findmatch' in order to shorten the code.

This commit is contained in:
Edoardo Prezioso 2011-12-30 11:36:09 +01:00
parent 6a0c463ebd
commit d0a3560c92
1 changed files with 5 additions and 7 deletions

View File

@ -2529,13 +2529,11 @@ bool Tokenizer::hasEnumsWithTypedef()
{
for (const Token *tok = _tokens; tok; tok = tok->next()) {
if (Token::Match(tok, "enum %var% {")) {
for (const Token *tok2 = tok->tokAt(3); tok2; tok2 = tok2->next()) {
if (tok2->str() == "typedef") {
syntaxError(tok2);
return true;
} else if (tok2->str() == "}") {
break;
}
tok = tok->tokAt(2);
const Token *tok2 = Token::findmatch(tok, "typedef", tok->link());
if (tok2) {
syntaxError(tok2);
return true;
}
}
}