@@ -763,6 +763,15 @@ struct ScalarEnumerationTraits<FormatStyle::SpaceBeforeParensStyle> {
763763 }
764764};
765765
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+
766775template <> struct ScalarEnumerationTraits <FormatStyle::SpacesInAnglesStyle> {
767776 static void enumeration (IO &IO, FormatStyle::SpacesInAnglesStyle &Value) {
768777 IO.enumCase (Value, " Never" , FormatStyle::SIAS_Never);
@@ -931,6 +940,7 @@ template <> struct MappingTraits<FormatStyle> {
931940 bool DeriveLineEnding = true ;
932941 bool UseCRLF = false ;
933942
943+ bool SpaceInEmptyBlock = false ;
934944 bool SpaceInEmptyParentheses = false ;
935945 bool SpacesInConditionalStatement = false ;
936946 bool SpacesInCStyleCastParentheses = false ;
@@ -960,6 +970,7 @@ template <> struct MappingTraits<FormatStyle> {
960970 IO.mapOptional (" PointerBindsToType" , Style.PointerAlignment );
961971 IO.mapOptional (" SpaceAfterControlStatementKeyword" ,
962972 Style.SpaceBeforeParens );
973+ IO.mapOptional (" SpaceInEmptyBlock" , SpaceInEmptyBlock);
963974 IO.mapOptional (" SpaceInEmptyParentheses" , SpaceInEmptyParentheses);
964975 IO.mapOptional (" SpacesInConditionalStatement" ,
965976 SpacesInConditionalStatement);
@@ -1193,7 +1204,7 @@ template <> struct MappingTraits<FormatStyle> {
11931204 Style.SpaceBeforeRangeBasedForLoopColon );
11941205 IO.mapOptional (" SpaceBeforeSquareBrackets" ,
11951206 Style.SpaceBeforeSquareBrackets );
1196- IO.mapOptional (" SpaceInEmptyBlock " , Style.SpaceInEmptyBlock );
1207+ IO.mapOptional (" SpaceInEmptyBraces " , Style.SpaceInEmptyBraces );
11971208 IO.mapOptional (" SpacesBeforeTrailingComments" ,
11981209 Style.SpacesBeforeTrailingComments );
11991210 IO.mapOptional (" SpacesInAngles" , Style.SpacesInAngles );
@@ -1276,6 +1287,13 @@ template <> struct MappingTraits<FormatStyle> {
12761287 Style.LineEnding = FormatStyle::LE_DeriveCRLF;
12771288 }
12781289
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+
12791297 if (Style.SpacesInParens != FormatStyle::SIPO_Custom &&
12801298 (SpacesInParentheses || SpaceInEmptyParentheses ||
12811299 SpacesInConditionalStatement || SpacesInCStyleCastParentheses)) {
@@ -1677,7 +1695,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
16771695 LLVMStyle.SpaceBeforeParensOptions .AfterIfMacros = true ;
16781696 LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true ;
16791697 LLVMStyle.SpaceBeforeSquareBrackets = false ;
1680- LLVMStyle.SpaceInEmptyBlock = false ;
1698+ LLVMStyle.SpaceInEmptyBraces = FormatStyle::SIEB_Never ;
16811699 LLVMStyle.SpacesBeforeTrailingComments = 1 ;
16821700 LLVMStyle.SpacesInAngles = FormatStyle::SIAS_Never;
16831701 LLVMStyle.SpacesInContainerLiterals = true ;
@@ -1984,7 +2002,7 @@ FormatStyle getWebKitStyle() {
19842002 Style.ObjCSpaceAfterProperty = true ;
19852003 Style.PointerAlignment = FormatStyle::PAS_Left;
19862004 Style.SpaceBeforeCpp11BracedList = true ;
1987- Style.SpaceInEmptyBlock = true ;
2005+ Style.SpaceInEmptyBraces = FormatStyle::SIEB_Always ;
19882006 return Style;
19892007}
19902008
0 commit comments