rsmith added a comment.

I wonder if this can be fixed more generally by using 
`TokenConcatenation::AvoidConcat` to determine whether `clang-format` should 
require a space between two tokens. This is the logic that `clang -E` uses when 
printing preprocessed tokens to avoid token splices. For example, that should 
also stop `clang-format` breaking the last line of this:

  struct A;
  void operator<=(A, A);
  template<void(A, A)>
  struct B {};
  B<operator<= > b;



================
Comment at: clang/lib/Format/TokenAnnotator.cpp:3884
   if (Style.isCpp()) {
+    if (Right.is(tok::period) && Left.is(tok::numeric_constant))
+      return true;
----------------
owenpan wrote:
> HazardyKnusperkeks wrote:
> > Add a comment what that is? Without the bug report I'd not know what that 
> > sequence would be.
> I could do that, but the github issue is linked in the summary above and will 
> be in the commit message. In general, I don't like unnecessary comments 
> littered in the source. They can become outdated, out of place, misleading, 
> and even wrong. How about giving an example as shown above?
Does `clang-format` have any formatting modes where it would leave out spaces 
around `+` or `-`? The same issue arises with things like `0xe + n`, where 
removing the space between the `0xe` and the `+` results in a token splice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143546

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to