clang-format: Treat a trailing comment like a trailing comma in braced lists.
Before:
static StructInitInfo module = {MODULE_BUILTIN, /* type */
"streams" /* name */
};
After:
static StructInitInfo module = {
MODULE_BUILTIN, /* type */
"streams" /* name */
};
This fixes llvm.org/PR19378.
llvm-svn: 205851
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 5f44c5b..d7f1d0b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4516,8 +4516,9 @@
verifyIndependentOfContext("f(b * /* confusing comment */ ++c);");
verifyFormat(
- "int *MyValues = {*A, // Operator detection might be confused by the '{'\n"
- " *BB // Operator detection might be confused by previous comment\n"
+ "int *MyValues = {\n"
+ " *A, // Operator detection might be confused by the '{'\n"
+ " *BB // Operator detection might be confused by previous comment\n"
"};");
verifyIndependentOfContext("if (int *a = &b)");
@@ -5072,7 +5073,10 @@
" bbbbbbbbbbbbbbbbbbbb, bbbbb };",
ExtraSpaces);
verifyFormat("DoSomethingWithVector({} /* No data */);", ExtraSpaces);
- verifyFormat("DoSomethingWithVector({ {} /* No data */ }, { { 1, 2 } });",
+ verifyFormat("DoSomethingWithVector({\n"
+ " {} /* No data */\n"
+ " },\n"
+ " { { 1, 2 } });",
ExtraSpaces);
verifyFormat(
"someFunction(OtherParam,\n"