Skip to content

Commit bd6f964

Browse files
committed
updates from review
1 parent 0439c00 commit bd6f964

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

clang/include/clang/Format/Format.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,11 +1212,11 @@ struct FormatStyle {
12121212
/// \version 3.7
12131213
bool BinPackArguments;
12141214

1215-
/// If ``BinPackLongBracedLists`` is ``true`` it overrides
1215+
/// If ``BinPackLongBracedList`` is ``true`` it overrides
12161216
/// ``BinPackArguments`` if there are 20 or more items in a braced
12171217
/// initializer list.
12181218
/// \code
1219-
/// BinPackLongBracedLists: false vs. BinPackLongBracedLists: true
1219+
/// BinPackLongBracedList: false vs. BinPackLongBracedList: true
12201220
/// vector<int> x{ vector<int> x{1, 2, ...,
12211221
/// 20, 21};
12221222
/// 1,
@@ -1226,7 +1226,7 @@ struct FormatStyle {
12261226
/// 21};
12271227
/// \endcode
12281228
/// \version 21
1229-
bool BinPackLongBracedLists;
1229+
bool BinPackLongBracedList;
12301230

12311231
/// Different way to try to fit all parameters on a line.
12321232
enum BinPackParametersStyle : int8_t {
@@ -2564,8 +2564,6 @@ struct FormatStyle {
25642564
/// the parentheses of a function call with that name. If there is no name,
25652565
/// a zero-length name is assumed.
25662566
///
2567-
/// ``BinPackArguments`` may be forced to true for initializer lists with
2568-
/// more than 20 items if ``BinPackLongBracedLists`` is true.
25692567
/// \code
25702568
/// true: false:
25712569
/// vector<int> x{1, 2, 3, 4}; vs. vector<int> x{ 1, 2, 3, 4 };
@@ -5285,7 +5283,7 @@ struct FormatStyle {
52855283
R.AlwaysBreakBeforeMultilineStrings &&
52865284
AttributeMacros == R.AttributeMacros &&
52875285
BinPackArguments == R.BinPackArguments &&
5288-
BinPackLongBracedLists == R.BinPackLongBracedLists &&
5286+
BinPackLongBracedList == R.BinPackLongBracedList &&
52895287
BinPackParameters == R.BinPackParameters &&
52905288
BitFieldColonSpacing == R.BitFieldColonSpacing &&
52915289
BracedInitializerIndentWidth == R.BracedInitializerIndentWidth &&

clang/lib/Format/Format.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ template <> struct MappingTraits<FormatStyle> {
995995
Style.AlwaysBreakBeforeMultilineStrings);
996996
IO.mapOptional("AttributeMacros", Style.AttributeMacros);
997997
IO.mapOptional("BinPackArguments", Style.BinPackArguments);
998-
IO.mapOptional("BinPackLongBracedLists", Style.BinPackLongBracedLists);
998+
IO.mapOptional("BinPackLongBracedList", Style.BinPackLongBracedList);
999999
IO.mapOptional("BinPackParameters", Style.BinPackParameters);
10001000
IO.mapOptional("BitFieldColonSpacing", Style.BitFieldColonSpacing);
10011001
IO.mapOptional("BracedInitializerIndentWidth",
@@ -1508,7 +1508,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
15081508
LLVMStyle.AlwaysBreakBeforeMultilineStrings = false;
15091509
LLVMStyle.AttributeMacros.push_back("__capability");
15101510
LLVMStyle.BinPackArguments = true;
1511-
LLVMStyle.BinPackLongBracedLists = true;
1511+
LLVMStyle.BinPackLongBracedList = true;
15121512
LLVMStyle.BinPackParameters = FormatStyle::BPPS_BinPack;
15131513
LLVMStyle.BitFieldColonSpacing = FormatStyle::BFCS_Both;
15141514
LLVMStyle.BracedInitializerIndentWidth = std::nullopt;

clang/lib/Format/FormatToken.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
175175
// have many items (20 or more) or we allow bin-packing of function call
176176
// arguments.
177177
if (Style.Cpp11BracedListStyle && !Style.BinPackArguments &&
178-
(Commas.size() < 19 || !Style.BinPackLongBracedLists)) {
178+
(Commas.size() < 19 || !Style.BinPackLongBracedList)) {
179179
return;
180180
}
181181

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
168168
CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
169169
CHECK_PARSE_BOOL(AllowShortNamespacesOnASingleLine);
170170
CHECK_PARSE_BOOL(BinPackArguments);
171-
CHECK_PARSE_BOOL(BinPackLongBracedLists);
171+
CHECK_PARSE_BOOL(BinPackLongBracedList);
172172
CHECK_PARSE_BOOL(BreakAdjacentStringLiterals);
173173
CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
174174
CHECK_PARSE_BOOL(BreakBeforeTemplateCloser);

clang/unittests/Format/FormatTest.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14405,7 +14405,7 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
1440514405
" ddddd,\n"
1440614406
" eeeee,\n"
1440714407
" ffffff,\n"
14408-
" ggggg,\n"
14408+
" gggggg,\n"
1440914409
" hhhhhh,\n"
1441014410
" iiiiii,\n"
1441114411
" jjjjjj,\n"
@@ -14419,7 +14419,8 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
1441914419
" ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk,\n"
1442014420
"};",
1442114421
NoBinPacking);
14422-
NoBinPacking.BinPackLongBracedLists = false;
14422+
14423+
NoBinPacking.BinPackLongBracedList = false;
1442314424
verifyFormat("const Aaaaaa aaaaa = {\n"
1442414425
" aaaaa,\n"
1442514426
" bbbbb,\n"
@@ -14440,11 +14441,29 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
1444014441
" ffffff,\n"
1444114442
" ggggg,\n"
1444214443
" hhhhhh,\n"
14443-
" iiiiii,\n"
14444-
" jjjjjj,\n"
14445-
" kkkkkk,\n"
1444614444
"};",
1444714445
NoBinPacking);
14446+
verifyFormat("const Aaaaaa aaaaa = {aaaaa,\n"
14447+
" bbbbb,\n"
14448+
" ccccc,\n"
14449+
" ddddd,\n"
14450+
" eeeee,\n"
14451+
" ffffff,\n"
14452+
" ggggg,\n"
14453+
" hhhhhh,\n"
14454+
" iiiiii,\n"
14455+
" jjjjjj,\n"
14456+
" kkkkkk,\n"
14457+
" aaaaa,\n"
14458+
" bbbbb,\n"
14459+
" ccccc,\n"
14460+
" ddddd,\n"
14461+
" eeeee,\n"
14462+
" ffffff,\n"
14463+
" ggggg,\n"
14464+
" hhhhhh,\n"
14465+
" iiiiii};",
14466+
NoBinPacking);
1444814467

1444914468
NoBinPacking.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
1445014469
verifyFormat("static uint8 CddDp83848Reg[] = {\n"

0 commit comments

Comments
 (0)