use early continue

This commit is contained in:
Daniel Marjamäki 2017-12-27 22:29:45 +01:00
parent 469cb7e6df
commit 42bcb6d417
1 changed files with 24 additions and 24 deletions

View File

@ -471,30 +471,30 @@ std::list<TemplateSimplifier::TokenAndName> TemplateSimplifier::getTemplateDecla
std::list<TokenAndName> declarations; std::list<TokenAndName> declarations;
for (Token *tok = tokens; tok; tok = tok->next()) { for (Token *tok = tokens; tok; tok = tok->next()) {
setScopeInfo(tok, &scopeInfo); setScopeInfo(tok, &scopeInfo);
if (Token::simpleMatch(tok, "template <")) { if (!Token::simpleMatch(tok, "template <"))
// Some syntax checks, see #6865 continue;
if (!tok->tokAt(2)) // Some syntax checks, see #6865
syntaxError(tok->next()); if (!tok->tokAt(2))
if (tok->strAt(2)=="typename" && syntaxError(tok->next());
(!tok->tokAt(3) || !Token::Match(tok->tokAt(3), "%name%|.|,|>"))) if (tok->strAt(2)=="typename" &&
syntaxError(tok->next()); (!tok->tokAt(3) || !Token::Match(tok->tokAt(3), "%name%|.|,|>")))
codeWithTemplates = true; syntaxError(tok->next());
Token *parmEnd = tok->next()->findClosingBracket(); codeWithTemplates = true;
for (const Token *tok2 = parmEnd; tok2; tok2 = tok2->next()) { Token *parmEnd = tok->next()->findClosingBracket();
if (tok2->str() == "(") for (const Token *tok2 = parmEnd; tok2; tok2 = tok2->next()) {
tok2 = tok2->link(); if (tok2->str() == "(")
else if (tok2->str() == ")") tok2 = tok2->link();
break; else if (tok2->str() == ")")
// Just a declaration => ignore this break;
else if (tok2->str() == ";") // Just a declaration => ignore this
break; else if (tok2->str() == ";")
// Implementation => add to "templates" break;
else if (tok2->str() == "{") { // Implementation => add to "templates"
int namepos = getTemplateNamePosition(parmEnd); else if (tok2->str() == "{") {
if (namepos > 0) int namepos = getTemplateNamePosition(parmEnd);
declarations.push_back(TokenAndName(tok, getFullName(scopeInfo, parmEnd->strAt(namepos)))); if (namepos > 0)
break; declarations.push_back(TokenAndName(tok, getFullName(scopeInfo, parmEnd->strAt(namepos))));
} break;
} }
} }
} }