@@ -500,7 +500,7 @@ class LineJoiner {
500
500
: 0 ;
501
501
}
502
502
503
- auto TryMergeShortRecord = [&]() {
503
+ auto TryMergeShortRecord = [&] {
504
504
switch (Style.AllowShortRecordOnASingleLine ) {
505
505
case FormatStyle::SRS_Never:
506
506
return false ;
@@ -527,7 +527,7 @@ class LineJoiner {
527
527
// correctly elsewhere.
528
528
ShouldMerge =
529
529
!Style.BraceWrapping .AfterClass ||
530
- (TryMergeShortRecord () && !Style.BraceWrapping .SplitEmptyRecord );
530
+ (!Style.BraceWrapping .SplitEmptyRecord && TryMergeShortRecord () );
531
531
}
532
532
} else if (TheLine->InPPDirective ||
533
533
!TheLine->First ->isOneOf (tok::kw_class, tok::kw_enum,
@@ -904,7 +904,11 @@ class LineJoiner {
904
904
} else if (Limit != 0 && !Line.startsWithNamespace () &&
905
905
!startsExternCBlock (Line)) {
906
906
// Merge short records only when requested.
907
- if (isRecordLBrace (*Line.Last ) &&
907
+ if (Line.Last ->isOneOf (TT_EnumLBrace, TT_RecordLBrace))
908
+ return 0 ;
909
+
910
+ if (Line.Last ->isOneOf (TT_ClassLBrace, TT_StructLBrace,
911
+ TT_UnionLBrace) &&
908
912
Style.AllowShortRecordOnASingleLine != FormatStyle::SRS_Always) {
909
913
return 0 ;
910
914
}
@@ -961,14 +965,16 @@ class LineJoiner {
961
965
Limit -= 2 ;
962
966
unsigned MergedLines = 0 ;
963
967
964
- const bool TryMergeBlock =
965
- Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never;
966
- const bool TryMergeRecord =
967
- Style.AllowShortRecordOnASingleLine == FormatStyle::SRS_Always;
968
- const bool NextIsEmptyBlock = I[1 ]->First == I[1 ]->Last && I + 2 != E &&
969
- I[2 ]->First ->is (tok::r_brace);
968
+ auto TryMergeBlock = [&] {
969
+ if (Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never ||
970
+ Style.AllowShortRecordOnASingleLine == FormatStyle::SRS_Always) {
971
+ return true ;
972
+ }
973
+ return I[1 ]->First == I[1 ]->Last && I + 2 != E &&
974
+ I[2 ]->First ->is (tok::r_brace);
975
+ };
970
976
971
- if (TryMergeBlock || TryMergeRecord || NextIsEmptyBlock ) {
977
+ if (TryMergeBlock () ) {
972
978
MergedLines = tryMergeSimpleBlock (I + 1 , E, Limit);
973
979
// If we managed to merge the block, count the statement header, which
974
980
// is on a separate line.
0 commit comments