From 42bcb6d4175b42a7314d4921ce244f8c9d7b596b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 27 Dec 2017 22:29:45 +0100 Subject: [PATCH] use early continue --- lib/templatesimplifier.cpp | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 070fefc26..5c47ac5d3 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -471,30 +471,30 @@ std::list TemplateSimplifier::getTemplateDecla std::list declarations; for (Token *tok = tokens; tok; tok = tok->next()) { setScopeInfo(tok, &scopeInfo); - if (Token::simpleMatch(tok, "template <")) { - // Some syntax checks, see #6865 - if (!tok->tokAt(2)) - syntaxError(tok->next()); - if (tok->strAt(2)=="typename" && - (!tok->tokAt(3) || !Token::Match(tok->tokAt(3), "%name%|.|,|>"))) - syntaxError(tok->next()); - codeWithTemplates = true; - Token *parmEnd = tok->next()->findClosingBracket(); - for (const Token *tok2 = parmEnd; tok2; tok2 = tok2->next()) { - if (tok2->str() == "(") - tok2 = tok2->link(); - else if (tok2->str() == ")") - break; - // Just a declaration => ignore this - else if (tok2->str() == ";") - break; - // Implementation => add to "templates" - else if (tok2->str() == "{") { - int namepos = getTemplateNamePosition(parmEnd); - if (namepos > 0) - declarations.push_back(TokenAndName(tok, getFullName(scopeInfo, parmEnd->strAt(namepos)))); - break; - } + if (!Token::simpleMatch(tok, "template <")) + continue; + // Some syntax checks, see #6865 + if (!tok->tokAt(2)) + syntaxError(tok->next()); + if (tok->strAt(2)=="typename" && + (!tok->tokAt(3) || !Token::Match(tok->tokAt(3), "%name%|.|,|>"))) + syntaxError(tok->next()); + codeWithTemplates = true; + Token *parmEnd = tok->next()->findClosingBracket(); + for (const Token *tok2 = parmEnd; tok2; tok2 = tok2->next()) { + if (tok2->str() == "(") + tok2 = tok2->link(); + else if (tok2->str() == ")") + break; + // Just a declaration => ignore this + else if (tok2->str() == ";") + break; + // Implementation => add to "templates" + else if (tok2->str() == "{") { + int namepos = getTemplateNamePosition(parmEnd); + if (namepos > 0) + declarations.push_back(TokenAndName(tok, getFullName(scopeInfo, parmEnd->strAt(namepos)))); + break; } } }