clang-format: Don't use column layout with AlignAfterOpenBrackets.
authorDaniel Jasper <djasper@google.com>
Thu, 27 Nov 2014 14:40:48 +0000 (14:40 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 27 Nov 2014 14:40:48 +0000 (14:40 +0000)
This fixes llvm.org/PR21676.

llvm-svn: 222886

clang/lib/Format/FormatToken.cpp
clang/unittests/Format/FormatTestJava.cpp

index 677f1a0..badb3a3 100644 (file)
@@ -138,6 +138,10 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
       Commas.size() < 19)
     return;
 
+  // Column format doesn't really make sense if we don't align after brackets.
+  if (!Style.AlignAfterOpenBracket)
+    return;
+
   FormatToken *ItemBegin = Token->Next;
   SmallVector<bool, 8> MustBreakBeforeItem;
 
index 829ced7..95d1961 100644 (file)
@@ -212,6 +212,13 @@ TEST_F(FormatTestJava, ArrayInitializers) {
   verifyFormat("new int[] {\n"
                "    1, 2, 3, 4,\n"
                "};");
+
+  FormatStyle Style = getStyleWithColumns(65);
+  Style.Cpp11BracedListStyle = false;
+  verifyFormat(
+      "expected = new int[] { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n"
+      "  100, 100, 100, 100, 100, 100, 100, 100, 100, 100 };",
+      Style);
 }
 
 TEST_F(FormatTestJava, ThrowsDeclarations) {