Skip to content

Commit b4e35c6

Browse files
committed
[clang-format] Insert a space between a numeric UDL and a dot
Fixes llvm#60576. Differential Revision: https://reviews.llvm.org/D143546
1 parent e5906f6 commit b4e35c6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3893,6 +3893,9 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
38933893
return true;
38943894

38953895
if (Style.isCpp()) {
3896+
// Space between UDL and dot: auto b = 4s .count();
3897+
if (Right.is(tok::period) && Left.is(tok::numeric_constant))
3898+
return true;
38963899
// Space between import <iostream>.
38973900
// or import .....;
38983901
if (Left.is(Keywords.kw_import) && Right.isOneOf(tok::less, tok::ellipsis))

clang/unittests/Format/FormatTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25407,6 +25407,11 @@ TEST_F(FormatTest, InsertNewlineAtEOF) {
2540725407
verifyFormat("int i;\n", "int i;", Style);
2540825408
}
2540925409

25410+
TEST_F(FormatTest, SpaceAfterUDL) {
25411+
verifyFormat("auto c = (4s).count();");
25412+
verifyFormat("auto x = 5s .count() == 5;");
25413+
}
25414+
2541025415
} // namespace
2541125416
} // namespace format
2541225417
} // namespace clang

0 commit comments

Comments
 (0)