]> granicus.if.org Git - clang/commitdiff
clang-format: Guard the bin-packing in braced lists on BinPackArguments
authorDaniel Jasper <djasper@google.com>
Tue, 26 May 2015 07:26:26 +0000 (07:26 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 26 May 2015 07:26:26 +0000 (07:26 +0000)
instead of BinPackParameters. Braced lists are used as constructor
calls in many places and so the bin-packing should follow what is done
for other calls and not what is done for function declarations.

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

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

index 623e086992639df7979855b00f43a5a485029833..3234e084f2f80fd56509a9a5808290ec2e560c0e 100644 (file)
@@ -856,7 +856,7 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
     const FormatToken *NextNoComment = Current.getNextNonComment();
     AvoidBinPacking =
         Current.isOneOf(TT_ArrayInitializerLSquare, TT_DictLiteral) ||
-        Style.Language == FormatStyle::LK_Proto || !Style.BinPackParameters ||
+        Style.Language == FormatStyle::LK_Proto || !Style.BinPackArguments ||
         (NextNoComment && NextNoComment->is(TT_DesignatedInitializerPeriod));
   } else {
     NewIndent = Style.ContinuationIndentWidth +
index 42036666b0b7288c657db891d8941b789efd389b..88678ca1abe1a9bd831d9b9ceb89d1d41f380f24 100644 (file)
@@ -134,9 +134,9 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
     return;
 
   // In C++11 braced list style, we should not format in columns unless they
-  // have many items (20 or more) or we allow bin-packing of function
-  // parameters.
-  if (Style.Cpp11BracedListStyle && !Style.BinPackParameters &&
+  // have many items (20 or more) or we allow bin-packing of function call
+  // arguments.
+  if (Style.Cpp11BracedListStyle && !Style.BinPackArguments &&
       Commas.size() < 19)
     return;
 
index 5100c8e9304c975dcab142f26766a8e2e7b716dd..ca50be98fe393f647b305ae2118d66c63dfddd18 100644 (file)
@@ -6219,9 +6219,9 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
                "  };\n"
                "};");
 
-  // In combination with BinPackParameters = false.
+  // In combination with BinPackArguments = false.
   FormatStyle NoBinPacking = getLLVMStyle();
-  NoBinPacking.BinPackParameters = false;
+  NoBinPacking.BinPackArguments = false;
   verifyFormat("const Aaaaaa aaaaa = {aaaaa,\n"
                "                      bbbbb,\n"
                "                      ccccc,\n"