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), ") {")) {
tok = tok->linkAt(1)->linkAt(1);
} else {
while (tok->str() != ";" && tok->str() != "{") {
if (tok->next() == nullptr) {
return tok;
}
const Token *switchToken = tok;
tok = tok->linkAt(1);
while (tok && !Token::Match(tok, "[;{}]"))
tok = tok->next();
}
if (!tok)
return switchToken;
if (tok->str() != ";")
return tok;
}
} else if (tok->str() == "(") {
tok = tok->link();