[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
Thu Mar 31 02:59:07 PDT 2022


owenpan requested changes to this revision.
owenpan added inline comments.
This revision now requires changes to proceed.


================
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))) {
----------------
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))) {
```


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