From 5c4458052891e25d3089efc0b51a2797ff747739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 16 Feb 2018 22:59:38 +0100 Subject: [PATCH] Refactoring, use early continue and make code a bit more specific. --- lib/tokenize.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7dd30298b..81b601c35 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8922,17 +8922,17 @@ void Tokenizer::simplifyCPPAttribute() return; for (Token *tok = list.front(); tok; tok = tok->next()) { - if (tok->link() && Token::Match(tok, "[ [ %name%")) { - if (tok->strAt(2) == "noreturn") { - const Token * head = tok->tokAt(5); - while (Token::Match(head, "%name%|::|*|&")) - head = head->next(); - if (head && isFunctionHead(head, "{|;")) - head->previous()->isAttributeNoreturn(true); - } - Token::eraseTokens(tok, tok->link()->next()); - tok->deleteThis(); + if (!tok->link() || !Token::Match(tok, "[ [ %name%")) + continue; + if (tok->strAt(2) == "noreturn") { + const Token * head = tok->link()->next(); + while (Token::Match(head, "%name%|::|*|&")) + head = head->next(); + if (head && head->str() == "(" && isFunctionHead(head, "{|;")) + head->previous()->isAttributeNoreturn(true); } + Token::eraseTokens(tok, tok->link()->next()); + tok->deleteThis(); } }