[PATCH] D121756: [clang-format] Clean up code looking for if statements NFC
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 1 17:26:30 PDT 2022
owenpan added inline comments.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:252-256
+ } else if (OpeningParen.isConditionLParen(/*IncludeFor=*/false) ||
+ (OpeningParen.Previous &&
+ OpeningParen.Previous->isOneOf(TT_BinaryOperator, tok::l_paren,
+ tok::comma,
+ tok::kw_static_assert))) {
----------------
owenpan wrote:
> I don't think this is NFC.
> Before:
> ```
> } else if (OpeningParen.Previous &&
> (OpeningParen.Previous->isOneOf(tok::kw_static_assert,
> tok::kw_while, tok::l_paren,
> tok::comma, tok::kw_if,
> TT_BinaryOperator) ||
> OpeningParen.Previous->endsSequence(tok::kw_constexpr,
> tok::kw_if) ||
> OpeningParen.Previous->endsSequence(tok::identifier,
> tok::kw_if))) {
> ```
> After:
> ```
> } else if ((OpeningParen.is(tok::l_paren) &&
> OpeningParen.is(TT_ConditionLParen)) ||
> // PreviousNonComment = OpeningParen.getPreviousNonComment()
> (PreviousNonComment &&
> PreviousNonComment->isOneOf(tok::kw_if, tok::kw_while,
> tok::kw_switch, tok::kw_case,
> tok::kw_constexpr)) ||
> (OpeningParen.Previous &&
> OpeningParen.Previous->isOneOf(tok::kw_static_assert,
> tok::l_paren, tok::comma,
> TT_BinaryOperator))) {
> ```
> After:
> ```
> } else if ((OpeningParen.is(tok::l_paren) &&
> OpeningParen.is(TT_ConditionLParen)) ||
> ...
> tok::kw_constexpr)) ||
> ...
> ```
After:
```
} else if ((OpeningParen.is(tok::l_paren) &&
(OpeningParen.is(TT_ConditionLParen) ||
...
tok::kw_constexpr)))) ||
...
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121756/new/
https://reviews.llvm.org/D121756
More information about the cfe-commits
mailing list