[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
Thu Feb 9 13:35:16 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4e35c63711b: [clang-format] Insert a space between a numeric UDL and a dot (authored by owenpan).
Changed prior to commit:
https://reviews.llvm.org/D143546?vs=495707&id=496226#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143546/new/
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
@@ -25407,6 +25407,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
@@ -3893,6 +3893,9 @@
return true;
if (Style.isCpp()) {
+ // Space between UDL and dot: auto b = 4s .count();
+ 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.496226.patch
Type: text/x-patch
Size: 1013 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230209/1987f0ca/attachment.bin>
More information about the cfe-commits
mailing list