@@ -270,7 +270,8 @@ class LineJoiner {
270
270
if (NextLine.First ->isOneOf (TT_ClassLBrace, TT_StructLBrace,
271
271
TT_UnionLBrace) &&
272
272
NextLine.First == NextLine.Last && I + 2 != E &&
273
- !I[2 ]->First ->is (tok::r_brace)) {
273
+ !I[2 ]->First ->is (tok::r_brace) &&
274
+ Style.AllowShortRecordOnASingleLine != FormatStyle::SRS_Never) {
274
275
if (unsigned MergedLines = tryMergeSimpleBlock (I, E, Limit))
275
276
return MergedLines;
276
277
}
@@ -279,7 +280,7 @@ class LineJoiner {
279
280
// Handle empty record blocks where the brace has already been wrapped.
280
281
if (PreviousLine && TheLine->Last ->is (tok::l_brace) &&
281
282
TheLine->First == TheLine->Last ) {
282
- bool EmptyBlock = NextLine.First ->is (tok::r_brace);
283
+ const bool EmptyBlock = NextLine.First ->is (tok::r_brace);
283
284
284
285
const FormatToken *Tok = PreviousLine->First ;
285
286
if (Tok && Tok->is (tok::comment))
@@ -295,7 +296,9 @@ class LineJoiner {
295
296
Tok = Tok->getNextNonComment ();
296
297
if (Tok && Tok->isOneOf (tok::kw_class, tok::kw_struct, tok::kw_union,
297
298
tok::kw_extern, Keywords.kw_interface )) {
298
- return !Style.BraceWrapping .SplitEmptyRecord && EmptyBlock
299
+ return (EmptyBlock && !Style.BraceWrapping .SplitEmptyRecord ) ||
300
+ (!EmptyBlock && Style.AllowShortBlocksOnASingleLine ==
301
+ FormatStyle::SBS_Always)
299
302
? tryMergeSimpleBlock (I, E, Limit)
300
303
: 0 ;
301
304
}
@@ -909,6 +912,7 @@ class LineJoiner {
909
912
910
913
if (Line.Last ->isOneOf (TT_ClassLBrace, TT_StructLBrace,
911
914
TT_UnionLBrace) &&
915
+ Line.Last != Line.First &&
912
916
Style.AllowShortRecordOnASingleLine != FormatStyle::SRS_Always) {
913
917
return 0 ;
914
918
}
0 commit comments