Refactoring, use early continue and make code a bit more specific.

This commit is contained in:
Daniel Marjamäki 2018-02-16 22:59:38 +01:00
parent fcde1d80e9
commit 5c44580528
1 changed files with 10 additions and 10 deletions

View File

@ -8922,19 +8922,19 @@ void Tokenizer::simplifyCPPAttribute()
return; return;
for (Token *tok = list.front(); tok; tok = tok->next()) { for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->link() && Token::Match(tok, "[ [ %name%")) { if (!tok->link() || !Token::Match(tok, "[ [ %name%"))
continue;
if (tok->strAt(2) == "noreturn") { if (tok->strAt(2) == "noreturn") {
const Token * head = tok->tokAt(5); const Token * head = tok->link()->next();
while (Token::Match(head, "%name%|::|*|&")) while (Token::Match(head, "%name%|::|*|&"))
head = head->next(); head = head->next();
if (head && isFunctionHead(head, "{|;")) if (head && head->str() == "(" && isFunctionHead(head, "{|;"))
head->previous()->isAttributeNoreturn(true); head->previous()->isAttributeNoreturn(true);
} }
Token::eraseTokens(tok, tok->link()->next()); Token::eraseTokens(tok, tok->link()->next());
tok->deleteThis(); tok->deleteThis();
} }
} }
}
static const std::set<std::string> keywords = make_container< std::set<std::string> >() static const std::set<std::string> keywords = make_container< std::set<std::string> >()
<< "volatile" << "volatile"