[clang] [clang-format] Fix parsing of `operator<() {}` (PR #75144)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 12 18:14:08 PST 2023


================
@@ -164,6 +167,12 @@ class AnnotatingParser {
                TT_OverloadedOperatorLParen))) {
         return false;
       }
+      FormatToken *ClosingParen = nullptr;
+      if (Previous.Previous->is(tok::kw_operator) &&
+          isFunctionDeclarationName(Style.isCpp(), *Previous.Previous, Line,
+                                    ClosingParen)) {
----------------
owenca wrote:

It seems that the following would suffice:
```suggestion
      if (Previous.Previous->is(tok::kw_operator) &&
          CurrentToken->is(tok::l_paren)) {
```

https://github.com/llvm/llvm-project/pull/75144


More information about the cfe-commits mailing list