浏览代码

clang-format: Don't use column layout with AlignAfterOpenBrackets.

This fixes llvm.org/PR21676.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222886 91177308-0d34-0410-b5e6-96231b3b80d8
Daniel Jasper 10 年之前
父节点
当前提交
e89a0fd73e
共有 2 个文件被更改,包括 11 次插入0 次删除
  1. 4 0
      lib/Format/FormatToken.cpp
  2. 7 0
      unittests/Format/FormatTestJava.cpp

+ 4 - 0
lib/Format/FormatToken.cpp

@@ -138,6 +138,10 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
       Commas.size() < 19)
       Commas.size() < 19)
     return;
     return;
 
 
+  // Column format doesn't really make sense if we don't align after brackets.
+  if (!Style.AlignAfterOpenBracket)
+    return;
+
   FormatToken *ItemBegin = Token->Next;
   FormatToken *ItemBegin = Token->Next;
   SmallVector<bool, 8> MustBreakBeforeItem;
   SmallVector<bool, 8> MustBreakBeforeItem;
 
 

+ 7 - 0
unittests/Format/FormatTestJava.cpp

@@ -212,6 +212,13 @@ TEST_F(FormatTestJava, ArrayInitializers) {
   verifyFormat("new int[] {\n"
   verifyFormat("new int[] {\n"
                "    1, 2, 3, 4,\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) {
 TEST_F(FormatTestJava, ThrowsDeclarations) {