[PATCH] D144709: [clang-format] Improve left to right const

Alexander Hederstaf via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 27 01:15:57 PST 2023


AlexanderHederstaf marked 6 inline comments as done.
AlexanderHederstaf added a comment.

Fixed comments and rebased. Tested right to left on the output of left to right and discovered two cases where the output code would not compile. Added new tests for those cases and I am working on improvements for right to left.



================
Comment at: clang/lib/Format/QualifierAlignmentFixer.cpp:231-232
+    // The case  `Foo() const volatile override` -> `Foo() const volatile
+    // override` The case  `Foo() volatile const final` -> `Foo() const volatile
+    // final`
+    if (PreviousCheck->is(tok::r_paren))
----------------
HazardyKnusperkeks wrote:
> `clang-format` did wrap your comment ;)
Re-arranged the comments.


================
Comment at: clang/lib/Format/QualifierAlignmentFixer.cpp:230
+    } else if (PreviousCheck->is(TT_TemplateCloser)) {
+      return PreviousCheck->MatchingParen->Previous->isNot(tok::kw_template);
+    } else if (PreviousCheck->isOneOf(TT_PointerOrReference, tok::identifier,
----------------
HazardyKnusperkeks wrote:
> AlexanderHederstaf wrote:
> > HazardyKnusperkeks wrote:
> > > That may be null, or not?
> > I assumed that if the token is identified as a template closer then there will exist an opener. As far as I am aware, something must preceed that opener.
> Then please add an assertion. So we would get a nice message if your assumption is wrong.
Added assertions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144709



More information about the cfe-commits mailing list