]> granicus.if.org Git - clang/commitdiff
clang-format: Make braced list formatting more consistent.
authorDaniel Jasper <djasper@google.com>
Thu, 26 Feb 2015 11:46:29 +0000 (11:46 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 26 Feb 2015 11:46:29 +0000 (11:46 +0000)
Before:
  Aaaa aaaaaaaaaaa{
      {
       a, // +1 indent weird.
       b, // trailing comma signals one per line.
      },  // trailing comma signals one per line.
  };

After:
  Aaaa aaaaaaaaaaa{
      {
          a, // better!?
          b, // trailing comma signals one per line.
      },     // trailing comma signals one per line.
  };

Interesting that this apparently was entirely untested :-(.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230627 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTest.cpp

index 7b36cac5dc1ed4d2dbf960106d9420e2ec741a06..7c2d916ac5c8d32b56460fefe3183c99ef0e1b96 100644 (file)
@@ -824,7 +824,6 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
       ++NewIndentLevel;
     } else {
       NewIndent = State.Stack.back().LastSpace + Style.ContinuationIndentWidth;
-      NewIndent = std::min(State.Column + 1, NewIndent);
     }
     const FormatToken *NextNoComment = Current.getNextNonComment();
     AvoidBinPacking =
index cc279699465f87a54eadf58eb874645917a24b1b..9738877e453d58c13a74d28b6728bb9063d01cda 100644 (file)
@@ -5943,6 +5943,11 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
   verifyFormat("std::vector<int> v = {1, 0 /* comment */};");
   verifyFormat("Node n{1, Node{1000}, //\n"
                "       2};");
+  verifyFormat("Aaaa aaaaaaa{\n"
+               "    {\n"
+               "        aaaa,\n"
+               "    },\n"
+               "};");
 
   // In combination with BinPackParameters = false.
   FormatStyle NoBinPacking = getLLVMStyle();