From 21a35de0d208148f6fe7edf6669325ccb308603e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 27 Jan 2018 22:26:43 +0100 Subject: [PATCH] Tokenizer: Refactoring garbage check --- lib/tokenize.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 19d08fdf5..0fc1efaeb 100755 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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();