@@ -763,6 +763,15 @@ struct ScalarEnumerationTraits<FormatStyle::SpaceBeforeParensStyle> {
763
763
}
764
764
};
765
765
766
+ template <>
767
+ struct ScalarEnumerationTraits <FormatStyle::SpaceInEmptyBracesStyle> {
768
+ static void enumeration (IO &IO, FormatStyle::SpaceInEmptyBracesStyle &Value) {
769
+ IO.enumCase (Value, " Always" , FormatStyle::SIEB_Always);
770
+ IO.enumCase (Value, " Block" , FormatStyle::SIEB_Block);
771
+ IO.enumCase (Value, " Never" , FormatStyle::SIEB_Never);
772
+ }
773
+ };
774
+
766
775
template <> struct ScalarEnumerationTraits <FormatStyle::SpacesInAnglesStyle> {
767
776
static void enumeration (IO &IO, FormatStyle::SpacesInAnglesStyle &Value) {
768
777
IO.enumCase (Value, " Never" , FormatStyle::SIAS_Never);
@@ -931,6 +940,7 @@ template <> struct MappingTraits<FormatStyle> {
931
940
bool DeriveLineEnding = true ;
932
941
bool UseCRLF = false ;
933
942
943
+ bool SpaceInEmptyBlock = false ;
934
944
bool SpaceInEmptyParentheses = false ;
935
945
bool SpacesInConditionalStatement = false ;
936
946
bool SpacesInCStyleCastParentheses = false ;
@@ -960,6 +970,7 @@ template <> struct MappingTraits<FormatStyle> {
960
970
IO.mapOptional (" PointerBindsToType" , Style.PointerAlignment );
961
971
IO.mapOptional (" SpaceAfterControlStatementKeyword" ,
962
972
Style.SpaceBeforeParens );
973
+ IO.mapOptional (" SpaceInEmptyBlock" , SpaceInEmptyBlock);
963
974
IO.mapOptional (" SpaceInEmptyParentheses" , SpaceInEmptyParentheses);
964
975
IO.mapOptional (" SpacesInConditionalStatement" ,
965
976
SpacesInConditionalStatement);
@@ -1193,7 +1204,7 @@ template <> struct MappingTraits<FormatStyle> {
1193
1204
Style.SpaceBeforeRangeBasedForLoopColon );
1194
1205
IO.mapOptional (" SpaceBeforeSquareBrackets" ,
1195
1206
Style.SpaceBeforeSquareBrackets );
1196
- IO.mapOptional (" SpaceInEmptyBlock " , Style.SpaceInEmptyBlock );
1207
+ IO.mapOptional (" SpaceInEmptyBraces " , Style.SpaceInEmptyBraces );
1197
1208
IO.mapOptional (" SpacesBeforeTrailingComments" ,
1198
1209
Style.SpacesBeforeTrailingComments );
1199
1210
IO.mapOptional (" SpacesInAngles" , Style.SpacesInAngles );
@@ -1276,6 +1287,13 @@ template <> struct MappingTraits<FormatStyle> {
1276
1287
Style.LineEnding = FormatStyle::LE_DeriveCRLF;
1277
1288
}
1278
1289
1290
+ // If SpaceInEmptyBlock was specified but SpaceInEmptyBraces was not,
1291
+ // initialize the latter from the former for backward compatibility.
1292
+ if (SpaceInEmptyBlock &&
1293
+ Style.SpaceInEmptyBraces == FormatStyle::SIEB_Never) {
1294
+ Style.SpaceInEmptyBraces = FormatStyle::SIEB_Block;
1295
+ }
1296
+
1279
1297
if (Style.SpacesInParens != FormatStyle::SIPO_Custom &&
1280
1298
(SpacesInParentheses || SpaceInEmptyParentheses ||
1281
1299
SpacesInConditionalStatement || SpacesInCStyleCastParentheses)) {
@@ -1677,7 +1695,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
1677
1695
LLVMStyle.SpaceBeforeParensOptions .AfterIfMacros = true ;
1678
1696
LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true ;
1679
1697
LLVMStyle.SpaceBeforeSquareBrackets = false ;
1680
- LLVMStyle.SpaceInEmptyBlock = false ;
1698
+ LLVMStyle.SpaceInEmptyBraces = FormatStyle::SIEB_Never ;
1681
1699
LLVMStyle.SpacesBeforeTrailingComments = 1 ;
1682
1700
LLVMStyle.SpacesInAngles = FormatStyle::SIAS_Never;
1683
1701
LLVMStyle.SpacesInContainerLiterals = true ;
@@ -1984,7 +2002,7 @@ FormatStyle getWebKitStyle() {
1984
2002
Style.ObjCSpaceAfterProperty = true ;
1985
2003
Style.PointerAlignment = FormatStyle::PAS_Left;
1986
2004
Style.SpaceBeforeCpp11BracedList = true ;
1987
- Style.SpaceInEmptyBlock = true ;
2005
+ Style.SpaceInEmptyBraces = FormatStyle::SIEB_Always ;
1988
2006
return Style;
1989
2007
}
1990
2008
0 commit comments