[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
Tue Feb 7 18:48:51 PST 2023


owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, rymiel.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/60576.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143546

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25312,6 +25312,11 @@
   verifyFormat("int i;\n", "int i;", Style);
 }
 
+TEST_F(FormatTest, SpaceAfterUDL) {
+  verifyFormat("auto c = (4s).count();");
+  verifyFormat("auto x = 5s .count() == 5;");
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3881,6 +3881,8 @@
     return true;
 
   if (Style.isCpp()) {
+    if (Right.is(tok::period) && Left.is(tok::numeric_constant))
+      return true;
     // Space between import <iostream>.
     // or import .....;
     if (Left.is(Keywords.kw_import) && Right.isOneOf(tok::less, tok::ellipsis))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143546.495707.patch
Type: text/x-patch
Size: 956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230208/b655f1eb/attachment.bin>


More information about the cfe-commits mailing list