[clang] [clang-format] Fix a bug in annotating TrailingReturnArrow (PR #69249)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 16 14:34:49 PDT 2023


================
@@ -3497,6 +3497,15 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
           Tok->setType(TT_TrailingReturnArrow);
           break;
         }
+        if (Tok->isNot(TT_TrailingAnnotation))
+          continue;
+        const auto *Next = Tok->Next;
+        if (!Next || Next->isNot(tok::l_paren))
+          continue;
+        Tok = Next->MatchingParen;
+        if (Tok)
+          continue;
+        break;
----------------
HazardyKnusperkeks wrote:

I find it rather confusing to have a loop, with a `break` at the end.
```suggestion
        if (!Tok)
          break;
```

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


More information about the cfe-commits mailing list