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

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 30 21:08:32 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))
----------------
owenca wrote:

> The point that's puzzling me is, why don't we treat https://github.com/llvm/llvm-project/commit/834ac2e205dd8e492d6084a7952e68e19a1f54db and https://github.com/llvm/llvm-project/commit/73c961a3345c697f40e2148318f34f5f347701c1 similarly.

The latter was an attempt at fixing both the regression caused by the former and the [issue](https://github.com/llvm/llvm-project/issues/100300#issuecomment-2249303341) with bitwise operators _outside_ templates. By the time the issue with bitwise operators _inside_ templates was [brought up](https://github.com/llvm/llvm-project/pull/108671#discussion_r1760689981), 392b77d58a91049a155f3390ec16941a848aa766 and another commit d9806ffe4e4d26de9c01f6b8ac0deae169b1d88d on top of it had already been released in 19.1.0.

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


More information about the cfe-commits mailing list