[PATCH] D143546: [clang-format] Insert a space between a numeric UDL and a dot
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 8 17:50:41 PST 2023
owenpan added a comment.
In D143546#4113730 <https://reviews.llvm.org/D143546#4113730>, @rsmith wrote:
> 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.
Probabtly not as clang-format uses the raw lexer that doesn't involve the preprocessor, which seems to be required by `TokenConcatenation`.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:3884
if (Style.isCpp()) {
+ if (Right.is(tok::period) && Left.is(tok::numeric_constant))
+ return true;
----------------
rsmith wrote:
> 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.
No. I was aware of them and had made sure clang-format already handled them correctly.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143546/new/
https://reviews.llvm.org/D143546
More information about the cfe-commits
mailing list