[clang] [clang-format] Fix a bug in annotating angles containing FatArrow (PR #108671)

kadir çetinkaya via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 00:56:24 PDT 2024


================
@@ -243,14 +244,16 @@ class AnnotatingParser {
       // operator that was misinterpreted because we are parsing template
       // parameters.
       // FIXME: This is getting out of hand, write a decent parser.
-      if (InExpr && !Line.startsWith(tok::kw_template) &&
+      if (InExpr && !SeenFatArrow && !Line.startsWith(tok::kw_template) &&
           Prev.is(TT_BinaryOperator)) {
         const auto Precedence = Prev.getPrecedence();
         if (Precedence > prec::Conditional && Precedence < prec::Relational)
           return false;
       }
       if (Prev.isOneOf(tok::question, tok::colon) && !Style.isProto())
         SeenTernaryOperator = true;
+      else if (Prev.is(TT_FatArrow))
----------------
kadircet wrote:

i am not sure if the regression is specific to fat-arrow here (sorry for not putting much effort into the reproducer). the original change seem to changed behavior for handling of any bitwise operators. so I think something like:
```cpp
auto foo = new Bar<kFoo | kBar>();
```

would also be formatted differently

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


More information about the cfe-commits mailing list