[clang] 3a3fcd6 - [clang-format] add regression tests for braced lists
Krasimir Georgiev via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 19 07:09:50 PST 2021
Author: Krasimir Georgiev
Date: 2021-12-19T16:07:07+01:00
New Revision: 3a3fcd6a23ad2c0f420a2f6bfde7541233790a30
URL: https://github.com/llvm/llvm-project/commit/3a3fcd6a23ad2c0f420a2f6bfde7541233790a30
DIFF: https://github.com/llvm/llvm-project/commit/3a3fcd6a23ad2c0f420a2f6bfde7541233790a30.diff
LOG: [clang-format] add regression tests for braced lists
Depends on https://reviews.llvm.org/D116000.
Added test cases from the comments on https://reviews.llvm.org/D114583.
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D116001
Added:
Modified:
clang/unittests/Format/FormatTest.cpp
Removed:
################################################################################
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index d12796e32e577..9325f622d228e 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -11515,6 +11515,17 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
" };\n"
"};");
verifyFormat("#define A {a, a},");
+ // Don't confuse braced list initializers with compound statements.
+ verifyFormat(
+ "class A {\n"
+ " A() : a{} {}\n"
+ " A(int b) : b(b) {}\n"
+ " A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
+ " int a, b;\n"
+ " explicit Expr(const Scalar<Result> &x) : u{Constant<Result>{x}} {}\n"
+ " explicit Expr(Scalar<Result> &&x) : u{Constant<Result>{std::move(x)}} "
+ "{}\n"
+ "};");
// Avoid breaking between equal sign and opening brace
FormatStyle AvoidBreakingFirstArgument = getLLVMStyle();
More information about the cfe-commits
mailing list