@@ -719,6 +719,23 @@ template <> struct MappingTraits<FormatStyle::SpacesInLineComment> {
719719 }
720720};
721721
722+ template <> struct MappingTraits <FormatStyle::SpaceInEmptyBracesCustom> {
723+ static void mapping (IO &IO, FormatStyle::SpaceInEmptyBracesCustom &Space) {
724+ IO.mapOptional (" Function" , Space.Function );
725+ IO.mapOptional (" Record" , Space.Record );
726+ IO.mapOptional (" InitList" , Space.InitList );
727+ IO.mapOptional (" Block" , Space.Block );
728+ }
729+ };
730+
731+ template <>
732+ struct ScalarEnumerationTraits <FormatStyle::SpaceInEmptyBracesStyle> {
733+ static void enumeration (IO &IO, FormatStyle::SpaceInEmptyBracesStyle &Value) {
734+ IO.enumCase (Value, " Never" , FormatStyle::SIEBO_Never);
735+ IO.enumCase (Value, " Custom" , FormatStyle::SIEBO_Custom);
736+ }
737+ };
738+
722739template <> struct MappingTraits <FormatStyle::SpacesInParensCustom> {
723740 static void mapping (IO &IO, FormatStyle::SpacesInParensCustom &Spaces) {
724741 IO.mapOptional (" InCStyleCasts" , Spaces.InCStyleCasts );
@@ -850,6 +867,7 @@ template <> struct MappingTraits<FormatStyle> {
850867 bool UseCRLF = false ;
851868
852869 bool SpaceInEmptyParentheses = false ;
870+ bool SpaceInEmptyBlock = false ;
853871 bool SpacesInConditionalStatement = false ;
854872 bool SpacesInCStyleCastParentheses = false ;
855873 bool SpacesInParentheses = false ;
@@ -876,6 +894,7 @@ template <> struct MappingTraits<FormatStyle> {
876894 IO.mapOptional (" SpaceAfterControlStatementKeyword" ,
877895 Style.SpaceBeforeParens );
878896 IO.mapOptional (" SpaceInEmptyParentheses" , SpaceInEmptyParentheses);
897+ IO.mapOptional (" SpaceInEmptyBlock" , SpaceInEmptyBlock);
879898 IO.mapOptional (" SpacesInConditionalStatement" ,
880899 SpacesInConditionalStatement);
881900 IO.mapOptional (" SpacesInCStyleCastParentheses" ,
@@ -1092,14 +1111,16 @@ template <> struct MappingTraits<FormatStyle> {
10921111 Style.SpaceBeforeRangeBasedForLoopColon );
10931112 IO.mapOptional (" SpaceBeforeSquareBrackets" ,
10941113 Style.SpaceBeforeSquareBrackets );
1095- IO.mapOptional (" SpaceInEmptyBlock" , Style.SpaceInEmptyBlock );
10961114 IO.mapOptional (" SpacesBeforeTrailingComments" ,
10971115 Style.SpacesBeforeTrailingComments );
10981116 IO.mapOptional (" SpacesInAngles" , Style.SpacesInAngles );
10991117 IO.mapOptional (" SpacesInContainerLiterals" ,
11001118 Style.SpacesInContainerLiterals );
11011119 IO.mapOptional (" SpacesInLineCommentPrefix" ,
11021120 Style.SpacesInLineCommentPrefix );
1121+ IO.mapOptional (" SpaceInEmptyBraces" , Style.SpaceInEmptyBraces );
1122+ IO.mapOptional (" SpaceInEmptyBracesOptions" ,
1123+ Style.SpaceInEmptyBracesOptions );
11031124 IO.mapOptional (" SpacesInParens" , Style.SpacesInParens );
11041125 IO.mapOptional (" SpacesInParensOptions" , Style.SpacesInParensOptions );
11051126 IO.mapOptional (" SpacesInSquareBrackets" , Style.SpacesInSquareBrackets );
@@ -1194,6 +1215,15 @@ template <> struct MappingTraits<FormatStyle> {
11941215 }
11951216 Style.SpacesInParens = FormatStyle::SIPO_Custom;
11961217 }
1218+
1219+ if (Style.SpaceInEmptyBraces != FormatStyle::SIEBO_Custom &&
1220+ SpaceInEmptyBlock) {
1221+ Style.SpaceInEmptyBraces = FormatStyle::SIEBO_Custom;
1222+ Style.SpaceInEmptyBracesOptions .Function = true ;
1223+ Style.SpaceInEmptyBracesOptions .Record = true ;
1224+ Style.SpaceInEmptyBracesOptions .InitList = false ;
1225+ Style.SpaceInEmptyBracesOptions .Block = true ;
1226+ }
11971227 }
11981228};
11991229
@@ -1563,7 +1593,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
15631593 LLVMStyle.SpaceBeforeParensOptions .AfterIfMacros = true ;
15641594 LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true ;
15651595 LLVMStyle.SpaceBeforeSquareBrackets = false ;
1566- LLVMStyle.SpaceInEmptyBlock = false ;
1596+ LLVMStyle.SpaceInEmptyBraces = FormatStyle::SIEBO_Never ;
15671597 LLVMStyle.SpacesBeforeTrailingComments = 1 ;
15681598 LLVMStyle.SpacesInAngles = FormatStyle::SIAS_Never;
15691599 LLVMStyle.SpacesInContainerLiterals = true ;
@@ -1864,7 +1894,11 @@ FormatStyle getWebKitStyle() {
18641894 Style.ObjCSpaceAfterProperty = true ;
18651895 Style.PointerAlignment = FormatStyle::PAS_Left;
18661896 Style.SpaceBeforeCpp11BracedList = true ;
1867- Style.SpaceInEmptyBlock = true ;
1897+ Style.SpaceInEmptyBraces = FormatStyle::SIEBO_Custom;
1898+ Style.SpaceInEmptyBracesOptions .Block = true ;
1899+ Style.SpaceInEmptyBracesOptions .InitList = true ;
1900+ Style.SpacesInParensOptions .InEmptyParentheses = false ;
1901+ Style.SpacesInParensOptions .Other = false ;
18681902 return Style;
18691903}
18701904
0 commit comments