[PATCH] D121754: [clang-format] Refactor determineStarAmpUsage

sstwcw via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 18 03:59:35 PDT 2022


sstwcw marked 5 inline comments as done.
sstwcw added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2146-2147
+    //   know how they can be followed by a star or amp.
+    // co_await, delete - It doesn't make sense to have them followed by a unary
+    //   `+` or `-`.
+    if (PrevToken->isOneOf(TT_ConditionalExpr, tok::l_paren, tok::comma,
----------------
MyDeveloperDay wrote:
> HazardyKnusperkeks wrote:
> > Especially here, why should a `+` after `delete` be a binary operator?
> > How much sense it makes doesn't matter, it is valid c++: https://gcc.godbolt.org/z/c1x1nn3Ej
> I'm also trying to understand did you mean you couldn't have
> 
> case -1:
> case +1:
> case +0:
> case  -0:
> 
> https://gcc.godbolt.org/z/qvE44d5xz
In the new version `+` following `delete` is a unary operator.  Previously I was under the impression that we only formatted code that is sensible.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2146-2147
+    //   know how they can be followed by a star or amp.
+    // co_await, delete - It doesn't make sense to have them followed by a unary
+    //   `+` or `-`.
+    if (PrevToken->isOneOf(TT_ConditionalExpr, tok::l_paren, tok::comma,
----------------
sstwcw wrote:
> MyDeveloperDay wrote:
> > HazardyKnusperkeks wrote:
> > > Especially here, why should a `+` after `delete` be a binary operator?
> > > How much sense it makes doesn't matter, it is valid c++: https://gcc.godbolt.org/z/c1x1nn3Ej
> > I'm also trying to understand did you mean you couldn't have
> > 
> > case -1:
> > case +1:
> > case +0:
> > case  -0:
> > 
> > https://gcc.godbolt.org/z/qvE44d5xz
> In the new version `+` following `delete` is a unary operator.  Previously I was under the impression that we only formatted code that is sensible.
> case -1:
> case +1:

I meant we couldn't have things like `case *x` or `case &x`.  Is the comment not clear enough?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121754



More information about the cfe-commits mailing list