clang-format: Improve handling of block comments in braced lists.
Before:
std::vector<int> v = {
1, 0 /* comment */
};
After:
std::vector<int> v = {1, 0 /* comment */};
llvm-svn: 216445
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 14c221b..f88bdaf 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5450,6 +5450,7 @@
verifyFormat("int foo(int i) { return fo1{}(i); }");
verifyFormat("int foo(int i) { return fo1{}(i); }");
verifyFormat("auto i = decltype(x){};");
+ verifyFormat("std::vector<int> v = {1, 0 /* comment */};");
// In combination with BinPackParameters = false.
FormatStyle NoBinPacking = getLLVMStyle();
@@ -5545,10 +5546,7 @@
" bbbbbbbbbbbbbbbbbbbb, bbbbb };",
ExtraSpaces);
verifyFormat("DoSomethingWithVector({} /* No data */);", ExtraSpaces);
- verifyFormat("DoSomethingWithVector({\n"
- " {} /* No data */\n"
- " },\n"
- " { { 1, 2 } });",
+ verifyFormat("DoSomethingWithVector({ {} /* No data */ }, { { 1, 2 } });",
ExtraSpaces);
verifyFormat(
"someFunction(OtherParam,\n"
@@ -5618,10 +5616,9 @@
" 1, 1, 1, 1, 1, 1, 1, 1, //\n"
"};",
getLLVMStyleWithColumns(39));
- verifyFormat("vector<int> x = {\n"
- " 1, 1, 1, 1, 1, 1, 1, 1,\n"
- " /**/ /**/\n"
- "};",
+ verifyFormat("vector<int> x = {1, 1, 1, 1,\n"
+ " 1, 1, 1, 1,\n"
+ " /**/ /**/};",
getLLVMStyleWithColumns(39));
verifyFormat("return {{aaaaaaaaaaaaaaaaaaaaa},\n"
" {aaaaaaaaaaaaaaaaaaa},\n"