Skip to content

Commit

Permalink
use short circuit, remove redundant match
Browse files Browse the repository at this point in the history
  • Loading branch information
ludviggunne committed Jan 5, 2025
1 parent 790a377 commit 92deff6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9416,14 +9416,13 @@ void Tokenizer::simplifyCPPAttribute()
if (head && head->str() == "(" && isFunctionHead(head, "{|;")) {
head->previous()->isAttributeNodiscard(true);
}
} else if ((Token::findsimplematch(tok->tokAt(2), "maybe_unused", tok->link()) && hasMaybeUnused)
|| (Token::findsimplematch(tok->tokAt(2), "__maybe_unused__", tok->link()) && hasMaybeUnusedUnderscores)) {
} else if ((hasMaybeUnusedUnderscores && Token::findsimplematch(tok->tokAt(2), "__maybe_unused__", tok->link()))
|| (hasMaybeUnused && Token::findsimplematch(tok->tokAt(2), "maybe_unused", tok->link()))) {
Token* head = skipCPPOrAlignAttribute(tok)->next();
while (isCPPAttribute(head) || isAlignAttribute(head))
head = skipCPPOrAlignAttribute(head)->next();
head->isAttributeMaybeUnused(true);
} else if (Token::findsimplematch(tok->tokAt(2), "gnu :: unused", tok->link()) ||
Token::findsimplematch(tok->tokAt(2), "unused", tok->link())) {
} else if (Token::findsimplematch(tok->tokAt(2), "unused", tok->link())) {
Token* head = skipCPPOrAlignAttribute(tok)->next();
while (isCPPAttribute(head) || isAlignAttribute(head))
head = skipCPPOrAlignAttribute(head)->next();
Expand Down

0 comments on commit 92deff6

Please sign in to comment.