This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Insert a space between a numeric UDL and a dot
ClosedPublic

Authored by owenpan on Feb 7 2023, 6:48 PM.

Diff Detail

Event Timeline

owenpan created this revision.Feb 7 2023, 6:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2023, 6:48 PM
owenpan requested review of this revision.Feb 7 2023, 6:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2023, 6:48 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rymiel accepted this revision.Feb 7 2023, 6:52 PM

I've been sniped! (but only because i spent hours discussing with people if the error is pedantically valid, which it turns out it is)

This revision is now accepted and ready to land.Feb 7 2023, 6:52 PM

I've been sniped! (but only because i spent hours discussing with people if the error is pedantically valid, which it turns out it is)

I was wondering why you didn't assign yourself. :) When I saw the bug report, I immediately remembered D134853#3829710 and knew it was indeed a bug. As this one is an invalid-code-generation bug, I wanted it fixed ASAP.

HazardyKnusperkeks added inline comments.
clang/lib/Format/TokenAnnotator.cpp
3896

Add a comment what that is? Without the bug report I'd not know what that sequence would be.

owenpan added inline comments.Feb 8 2023, 12:30 PM
clang/lib/Format/TokenAnnotator.cpp
3896

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?

As this one is an invalid-code-generation bug, I wanted it fixed ASAP.

Do you intend to backport it to the 16 release branch then?

rsmith added a subscriber: rsmith.Feb 8 2023, 12:42 PM

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;
clang/lib/Format/TokenAnnotator.cpp
3896

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.

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.

clang/lib/Format/TokenAnnotator.cpp
3896

No. I was aware of them and had made sure clang-format already handled them correctly.

As this one is an invalid-code-generation bug, I wanted it fixed ASAP.

Do you intend to backport it to the 16 release branch then?

I don't know but will go with whatever you, @MyDeveloperDay and @HazardyKnusperkeks prefer.

As this one is an invalid-code-generation bug, I wanted it fixed ASAP.

Do you intend to backport it to the 16 release branch then?

I don't know but will go with whatever you, @MyDeveloperDay and @HazardyKnusperkeks prefer.

I'd vote in favor, letting a code breaking bug knowingly in the most current (or to come? I don't follow that.) version would be let's say not nice.

clang/lib/Format/TokenAnnotator.cpp
3896

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?

If you do a git blame you can come to the commit and thus to the bug, but if you are just reading, at least I don't blame all the lines. There I think a comment is nice, and your proposal is a really nice one.
But I've accepted the patch as is, and so the decision is yours. :)

MyDeveloperDay added a comment.EditedFeb 9 2023, 1:27 PM

As this one is an invalid-code-generation bug, I wanted it fixed ASAP.

Do you intend to backport it to the 16 release branch then?

I don't know but will go with whatever you, @MyDeveloperDay and @HazardyKnusperkeks prefer.

honestly, I trust your judgement @owenpan. I'm ok either way.

This revision was landed with ongoing or failed builds.Feb 9 2023, 1:35 PM
This revision was automatically updated to reflect the committed changes.
owenpan marked an inline comment as done.Feb 9 2023, 1:37 PM

As this one is an invalid-code-generation bug, I wanted it fixed ASAP.

Do you intend to backport it to the 16 release branch then?

I don't know but will go with whatever you, @MyDeveloperDay and @HazardyKnusperkeks prefer.

I'd vote in favor, letting a code breaking bug knowingly in the most current (or to come? I don't follow that.) version would be let's say not nice.

+1.

clang/lib/Format/TokenAnnotator.cpp
3896

+1.

owenpan marked an inline comment as done.Feb 9 2023, 3:21 PM

As this one is an invalid-code-generation bug, I wanted it fixed ASAP.

Do you intend to backport it to the 16 release branch then?

I don't know but will go with whatever you, @MyDeveloperDay and @HazardyKnusperkeks prefer.

honestly, I trust your judgement @owenpan. I'm ok either way.

Thanks! I've added the backport request.