[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 3 13:12:42 PST 2020


MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2314
+      nextToken();
+      if (FormatTok->Tok.is(tok::less)) {
+        while (!FormatTok->Tok.is(tok::greater)) {
----------------
klimek wrote:
> MyDeveloperDay wrote:
> > miscco wrote:
> > > miscco wrote:
> > > > I guess you could use `parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum=*/false,/*ClosingBraceKind=*/tok::greater);` here?
> > > To be more specific, I am concerned what happens if you have multiple template arguments where a linebreak should occur. Is this still happening here?
> > > 
> > > 
> > > ```
> > > template <typename someLongTypename1, typename someLongTypename2>
> > > concept someVeryLongConceptName = someVeryLongConstraintName1<someLongTypename1 && someLongTypename2>;
> > > ```
> > This is formatted as
> > 
> > ```
> > template <typename someLongTypename1, typename someLongTypename2>
> > concept someVeryLongConceptName =
> >     someVeryLongConstraintName1<someLongTypename1 && someLongTypename2>;
> > ```
> This seems like a very detailed way to parse them; generally, we try to only parse rough structure here.
So whilst I tend to agree, and I've tried to write this loop to be less and it just didn't seem to catch the cases that had already been given in the unit tests,

This ended up being a lot likes its own parseStructuralElement, I think the difference here is that I've written it as a series of if's rather than a switch statement.

I feel I'd be happier to push the patch through then address individual specific cases



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

https://reviews.llvm.org/D79773



More information about the cfe-commits mailing list