[PATCH] D146844: [clang-format] Handle '_' in ud-suffix for IntegerLiteralSeparator

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 24 22:34:41 PDT 2023


owenpan added a comment.

In D146844#4220894 <https://reviews.llvm.org/D146844#4220894>, @rymiel wrote:

> 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.



================
Comment at: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp:122
     const auto Start = Text[0] == '0' ? 2 : 0;
-    auto End = Text.find_first_of("uUlLzZn");
+    auto End = Text.find_first_of(Suffix);
     if (End == StringRef::npos)
----------------
There is no need to search the prefix. Will update it when landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146844



More information about the cfe-commits mailing list