Tokenizer: Refactoring garbage check

This commit is contained in:
Daniel Marjamäki 2018-01-27 22:26:43 +01:00
parent 4d18d3948f
commit 21a35de0d2
1 changed files with 7 additions and 5 deletions

View File

@ -8350,12 +8350,14 @@ const Token * Tokenizer::findGarbageCode() const
if (Token::simpleMatch(tok->linkAt(1), ") {")) { if (Token::simpleMatch(tok->linkAt(1), ") {")) {
tok = tok->linkAt(1)->linkAt(1); tok = tok->linkAt(1)->linkAt(1);
} else { } else {
while (tok->str() != ";" && tok->str() != "{") { const Token *switchToken = tok;
if (tok->next() == nullptr) { tok = tok->linkAt(1);
return tok; while (tok && !Token::Match(tok, "[;{}]"))
}
tok = tok->next(); tok = tok->next();
} if (!tok)
return switchToken;
if (tok->str() != ";")
return tok;
} }
} else if (tok->str() == "(") { } else if (tok->str() == "(") {
tok = tok->link(); tok = tok->link();