Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 4dd7f12

Browse files
committed
clang-format: Guard the bin-packing in braced lists on BinPackArguments
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
1 parent 86cd455 commit 4dd7f12

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Diff for: lib/Format/ContinuationIndenter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
856856
const FormatToken *NextNoComment = Current.getNextNonComment();
857857
AvoidBinPacking =
858858
Current.isOneOf(TT_ArrayInitializerLSquare, TT_DictLiteral) ||
859-
Style.Language == FormatStyle::LK_Proto || !Style.BinPackParameters ||
859+
Style.Language == FormatStyle::LK_Proto || !Style.BinPackArguments ||
860860
(NextNoComment && NextNoComment->is(TT_DesignatedInitializerPeriod));
861861
} else {
862862
NewIndent = Style.ContinuationIndentWidth +

Diff for: lib/Format/FormatToken.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
134134
return;
135135

136136
// In C++11 braced list style, we should not format in columns unless they
137-
// have many items (20 or more) or we allow bin-packing of function
138-
// parameters.
139-
if (Style.Cpp11BracedListStyle && !Style.BinPackParameters &&
137+
// have many items (20 or more) or we allow bin-packing of function call
138+
// arguments.
139+
if (Style.Cpp11BracedListStyle && !Style.BinPackArguments &&
140140
Commas.size() < 19)
141141
return;
142142

Diff for: unittests/Format/FormatTest.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -6219,9 +6219,9 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
62196219
" };\n"
62206220
"};");
62216221

6222-
// In combination with BinPackParameters = false.
6222+
// In combination with BinPackArguments = false.
62236223
FormatStyle NoBinPacking = getLLVMStyle();
6224-
NoBinPacking.BinPackParameters = false;
6224+
NoBinPacking.BinPackArguments = false;
62256225
verifyFormat("const Aaaaaa aaaaa = {aaaaa,\n"
62266226
" bbbbb,\n"
62276227
" ccccc,\n"

0 commit comments

Comments
 (0)