MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: lichray, HazardyKnusperkeks, curdeius.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay requested review of this revision.
Looks like the work of D113393: [c++2b] Implement P0849R8 auto(x)
<https://reviews.llvm.org/D113393> requires manual clang-formatting
intervention.
Removal of the space between `auto` and `{}`
@lichray would this help?
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113826
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
@@ -22566,6 +22566,13 @@
EXPECT_EQ(Code, format(Code, Style));
}
+TEST_F(FormatTest, FormatDecayCopy) {
+ verifyFormat("foo(auto())");
+ verifyFormat("foo(auto{})");
+ verifyFormat("foo(auto({}))");
+ verifyFormat("foo(auto{{}})");
+}
+
} // namespace
} // namespace format
} // namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2940,6 +2940,10 @@
return true;
}
+ // auto{x}
+ if (Left.is(tok::kw_auto) && Right.is(tok::l_brace))
+ return false;
+
// requires clause Concept1<T> && Concept2<T>
if (Left.is(TT_ConstraintJunctions) && Right.is(tok::identifier))
return true;
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22566,6 +22566,13 @@
EXPECT_EQ(Code, format(Code, Style));
}
+TEST_F(FormatTest, FormatDecayCopy) {
+ verifyFormat("foo(auto())");
+ verifyFormat("foo(auto{})");
+ verifyFormat("foo(auto({}))");
+ verifyFormat("foo(auto{{}})");
+}
+
} // namespace
} // namespace format
} // namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2940,6 +2940,10 @@
return true;
}
+ // auto{x}
+ if (Left.is(tok::kw_auto) && Right.is(tok::l_brace))
+ return false;
+
// requires clause Concept1<T> && Concept2<T>
if (Left.is(TT_ConstraintJunctions) && Right.is(tok::identifier))
return true;
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits