This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Handle '_' in ud-suffix for IntegerLiteralSeparator
ClosedPublic

Authored by owenpan on Mar 24 2023, 1:31 PM.

Diff Detail

Event Timeline

owenpan created this revision.Mar 24 2023, 1:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2023, 1:31 PM
owenpan requested review of this revision.Mar 24 2023, 1:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2023, 1:31 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rymiel accepted this revision.Mar 24 2023, 4:34 PM

Could this possibly be an issue for more esoteric underscore-less UDLs, like i?
Does the code need to search for a suffix, could it not detect the absence of a digit? Sorry if the questions are silly, I haven't really looked at this part of the formatter in depth

This revision is now accepted and ready to land.Mar 24 2023, 4:34 PM

Could this possibly be an issue for more esoteric underscore-less UDLs, like i?
Does the code need to search for a suffix, could it not detect the absence of a digit? Sorry if the questions are silly, I haven't really looked at this part of the formatter in depth

Good questions. I had chosen searching for suffixes instead of the absence of digits/separators because the former is simpler and runs a little faster. I'll switch to the latter if and when there is a need for inserting separators into integer literals with ud-suffixes that don't start with an underscore, which are allowed in the standard library only.

clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
125

There is no need to search the prefix. Will update it when landing.

owenpan updated this revision to Diff 508293.Mar 25 2023, 3:48 AM

Don't format imaginary numbers.

owenpan updated this revision to Diff 508889.Mar 27 2023, 10:04 PM

Treats imaginary number suffixes (starting with an i) just like any user-defined suffixes (starting with an underscore). Also handles ud-suffixes (e.g. _km and _Pa) containing letters that can be part of a floating-point number.

owenpan requested review of this revision.Mar 27 2023, 10:09 PM
MyDeveloperDay accepted this revision.Mar 28 2023, 12:34 AM

I'm not going to use it, but I like what you've done ;-)

This revision is now accepted and ready to land.Mar 28 2023, 12:34 AM

I'm not going to use it, but I like what you've done ;-)

Thanks! I won't use it either. :)

This revision was landed with ongoing or failed builds.Mar 28 2023, 1:13 PM
This revision was automatically updated to reflect the committed changes.