[PATCH] D120278: [clang-format] Don't break semi after requires clause regardless of the chosen style
Björn Schäpers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 22 13:09:36 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG923c3755ea80: [clang-format] Don't break semi after requires clause ... (authored by HazardyKnusperkeks).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120278/new/
https://reviews.llvm.org/D120278
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
@@ -23861,6 +23861,11 @@
"}",
Style);
+ verifyFormat("template <typename T>\n"
+ "int bar(T t)\n"
+ " requires F<T>;",
+ Style);
+
Style.IndentRequiresClause = false;
verifyFormat("template <typename T>\n"
"requires F<T>\n"
@@ -23881,6 +23886,7 @@
verifyFormat("template <typename T> requires Foo<T> struct Bar {};\n"
"template <typename T> requires Foo<T> void bar() {}\n"
"template <typename T> void bar() requires Foo<T> {}\n"
+ "template <typename T> void bar() requires Foo<T>;\n"
"template <typename T> requires Foo<T> Bar(T) -> Bar<T>;",
Style);
@@ -23933,6 +23939,9 @@
"void bar()\n"
"requires Foo<T> {}\n"
"template <typename T>\n"
+ "void bar()\n"
+ "requires Foo<T>;\n"
+ "template <typename T>\n"
"requires Foo<T> Bar(T) -> Bar<T>;",
Style);
@@ -23992,6 +24001,7 @@
"template <typename T>\n"
"void bar() requires Foo<T>\n"
"{}\n"
+ "template <typename T> void bar() requires Foo<T>;\n"
"template <typename T> requires Foo<T>\n"
"Bar(T) -> Bar<T>;",
Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3963,7 +3963,7 @@
return Style.BreakBeforeConceptDeclarations == FormatStyle::BBCDS_Always;
return Style.AlwaysBreakTemplateDeclarations == FormatStyle::BTDS_Yes;
}
- if (Left.ClosesRequiresClause) {
+ if (Left.ClosesRequiresClause && Right.isNot(tok::semi)) {
switch (Style.RequiresClausePosition) {
case FormatStyle::RCPS_OwnLine:
case FormatStyle::RCPS_WithPreceding:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120278.410627.patch
Type: text/x-patch
Size: 2181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220222/0c1d8677/attachment.bin>
More information about the cfe-commits
mailing list