|
16 | 16 | #include "DefinitionBlockSeparator.h" |
17 | 17 | #include "IntegerLiteralSeparatorFixer.h" |
18 | 18 | #include "NamespaceEndCommentsFixer.h" |
| 19 | +#include "NumericLiteralCaseFixer.h" |
19 | 20 | #include "ObjCPropertyAttributeOrderFixer.h" |
20 | 21 | #include "QualifierAlignmentFixer.h" |
21 | 22 | #include "SortJavaScriptImports.h" |
@@ -472,6 +473,25 @@ struct ScalarEnumerationTraits<FormatStyle::NamespaceIndentationKind> { |
472 | 473 | } |
473 | 474 | }; |
474 | 475 |
|
| 476 | +template <> |
| 477 | +struct ScalarEnumerationTraits<FormatStyle::NumericLiteralComponentStyle> { |
| 478 | + static void enumeration(IO &IO, |
| 479 | + FormatStyle::NumericLiteralComponentStyle &Value) { |
| 480 | + IO.enumCase(Value, "Leave", FormatStyle::NLCS_Leave); |
| 481 | + IO.enumCase(Value, "Upper", FormatStyle::NLCS_Upper); |
| 482 | + IO.enumCase(Value, "Lower", FormatStyle::NLCS_Lower); |
| 483 | + } |
| 484 | +}; |
| 485 | + |
| 486 | +template <> struct MappingTraits<FormatStyle::NumericLiteralCaseStyle> { |
| 487 | + static void mapping(IO &IO, FormatStyle::NumericLiteralCaseStyle &Value) { |
| 488 | + IO.mapOptional("ExponentLetter", Value.ExponentLetter); |
| 489 | + IO.mapOptional("HexDigit", Value.HexDigit); |
| 490 | + IO.mapOptional("Prefix", Value.Prefix); |
| 491 | + IO.mapOptional("Suffix", Value.Suffix); |
| 492 | + } |
| 493 | +}; |
| 494 | + |
475 | 495 | template <> struct ScalarEnumerationTraits<FormatStyle::OperandAlignmentStyle> { |
476 | 496 | static void enumeration(IO &IO, FormatStyle::OperandAlignmentStyle &Value) { |
477 | 497 | IO.enumCase(Value, "DontAlign", FormatStyle::OAS_DontAlign); |
@@ -1121,6 +1141,7 @@ template <> struct MappingTraits<FormatStyle> { |
1121 | 1141 | IO.mapOptional("MaxEmptyLinesToKeep", Style.MaxEmptyLinesToKeep); |
1122 | 1142 | IO.mapOptional("NamespaceIndentation", Style.NamespaceIndentation); |
1123 | 1143 | IO.mapOptional("NamespaceMacros", Style.NamespaceMacros); |
| 1144 | + IO.mapOptional("NumericLiteralCase", Style.NumericLiteralCase); |
1124 | 1145 | IO.mapOptional("ObjCBinPackProtocolList", Style.ObjCBinPackProtocolList); |
1125 | 1146 | IO.mapOptional("ObjCBlockIndentWidth", Style.ObjCBlockIndentWidth); |
1126 | 1147 | IO.mapOptional("ObjCBreakBeforeNestedBlockParam", |
@@ -1653,6 +1674,10 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { |
1653 | 1674 | LLVMStyle.LineEnding = FormatStyle::LE_DeriveLF; |
1654 | 1675 | LLVMStyle.MaxEmptyLinesToKeep = 1; |
1655 | 1676 | LLVMStyle.NamespaceIndentation = FormatStyle::NI_None; |
| 1677 | + LLVMStyle.NumericLiteralCase = {/*ExponentLetter=*/FormatStyle::NLCS_Leave, |
| 1678 | + /*HexDigit=*/FormatStyle::NLCS_Leave, |
| 1679 | + /*Prefix=*/FormatStyle::NLCS_Leave, |
| 1680 | + /*Suffix=*/FormatStyle::NLCS_Leave}; |
1656 | 1681 | LLVMStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Auto; |
1657 | 1682 | LLVMStyle.ObjCBlockIndentWidth = 2; |
1658 | 1683 | LLVMStyle.ObjCBreakBeforeNestedBlockParam = true; |
@@ -3890,6 +3915,10 @@ reformat(const FormatStyle &Style, StringRef Code, |
3890 | 3915 | return IntegerLiteralSeparatorFixer().process(Env, Expanded); |
3891 | 3916 | }); |
3892 | 3917 |
|
| 3918 | + Passes.emplace_back([&](const Environment &Env) { |
| 3919 | + return NumericLiteralCaseFixer().process(Env, Expanded); |
| 3920 | + }); |
| 3921 | + |
3893 | 3922 | if (Style.isCpp()) { |
3894 | 3923 | if (Style.QualifierAlignment != FormatStyle::QAS_Leave) |
3895 | 3924 | addQualifierAlignmentFixerPasses(Expanded, Passes); |
|
0 commit comments