[PATCH] D134049: [clang-format] Disallow trailing return arrows to be operators

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 16 13:28:43 PDT 2022


HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2615
+      if (Current->isOneOf(tok::period, tok::arrow) &&
+          !Current->is(TT_TrailingReturnArrow)) {
         return PrecedenceArrowAndPeriod;
----------------



================
Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:448
+  EXPECT_EQ(Tokens[11]->FakeLParens.size(), 0u);
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
+
----------------
rymiel wrote:
> MyDeveloperDay wrote:
> > should you not check that Tokens[21] is a TT_TrailingReturnArrow?
> That's probably a good idea, thank you! (though the bug wasn't that `->` was misannotated, it was still a trailing return arrow, it just caused fake parentheses to be inserted earlier on)
Can you add the test for `ClosesRequiresClause`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134049/new/

https://reviews.llvm.org/D134049



More information about the cfe-commits mailing list