JavaScript allows parameter lists to include trailing commas:
myFunction(param1, param2,);
For symmetry with other parenthesized lists ([...], {...}), clang-format should
wrap parenthesized lists one-per-line if they contain a trailing comma:
myFunction(
param1,
param2,
);
This is particularly useful in function declarations or calls with many
arguments, e.g. commonly in constructors.
Differential Revision: https://reviews.llvm.org/D33023
llvm-svn: 303049
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index cec2544..0760414 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2106,7 +2106,7 @@
verifyIncompleteFormat("void f(\n"
"#if A\n"
- " );\n"
+ ");\n"
"#else\n"
"#endif");
}
@@ -4475,7 +4475,7 @@
EXPECT_EQ("static_cast<A< //\n"
" B> *>(\n"
"\n"
- " );",
+ ");",
format("static_cast<A<//\n"
" B>*>(\n"
"\n"
@@ -6567,7 +6567,7 @@
"#if !TEST\n"
" _T(\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXn\")\n"
"#endif\n"
- " );",
+ ");",
format("f(\n"
"#if !TEST\n"
"_T(\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXn\")\n"
@@ -9639,7 +9639,7 @@
// Other corner cases.
verifyFormat("void f() {\n"
" bar([]() {} // Did not respect SpacesBeforeTrailingComments\n"
- " );\n"
+ " );\n"
"}");
// Lambdas created through weird macros.