@@ -659,15 +659,26 @@ template <> struct ScalarEnumerationTraits<FormatStyle::ShortLambdaStyle> {
659659 }
660660};
661661
662- template <> struct ScalarEnumerationTraits <FormatStyle::SortIncludesOptions> {
663- static void enumeration (IO &IO, FormatStyle::SortIncludesOptions &Value) {
664- IO.enumCase (Value, " Never" , FormatStyle::SI_Never);
665- IO.enumCase (Value, " CaseInsensitive" , FormatStyle::SI_CaseInsensitive);
666- IO.enumCase (Value, " CaseSensitive" , FormatStyle::SI_CaseSensitive);
662+ template <> struct MappingTraits <FormatStyle::SortIncludesOptions> {
663+ static void enumInput (IO &IO, FormatStyle::SortIncludesOptions &Value) {
664+ IO.enumCase (Value, " Never" , FormatStyle::SortIncludesOptions ({}));
665+ IO.enumCase (Value, " CaseInsensitive" ,
666+ FormatStyle::SortIncludesOptions ({/* Enabled=*/ true ,
667+ /* IgnoreCase=*/ true }));
668+ IO.enumCase (Value, " CaseSensitive" ,
669+ FormatStyle::SortIncludesOptions ({/* Enabled=*/ true ,
670+ /* IgnoreCase=*/ false }));
667671
668672 // For backward compatibility.
669- IO.enumCase (Value, " false" , FormatStyle::SI_Never);
670- IO.enumCase (Value, " true" , FormatStyle::SI_CaseSensitive);
673+ IO.enumCase (Value, " false" , FormatStyle::SortIncludesOptions ({}));
674+ IO.enumCase (Value, " true" ,
675+ FormatStyle::SortIncludesOptions ({/* Enabled=*/ true ,
676+ /* IgnoreCase=*/ false }));
677+ }
678+
679+ static void mapping (IO &IO, FormatStyle::SortIncludesOptions &Value) {
680+ IO.mapOptional (" Enabled" , Value.Enabled );
681+ IO.mapOptional (" IgnoreCase" , Value.IgnoreCase );
671682 }
672683};
673684
@@ -1636,7 +1647,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
16361647 LLVMStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Leave;
16371648 LLVMStyle.ShortNamespaceLines = 1 ;
16381649 LLVMStyle.SkipMacroDefinitionBody = false ;
1639- LLVMStyle.SortIncludes = FormatStyle::SI_CaseSensitive ;
1650+ LLVMStyle.SortIncludes = { /* Enabled= */ true , /* IgnoreCase= */ false } ;
16401651 LLVMStyle.SortJavaStaticImport = FormatStyle::SJSIO_Before;
16411652 LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric;
16421653 LLVMStyle.SpaceAfterCStyleCast = false ;
@@ -1901,7 +1912,6 @@ FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) {
19011912 " java" ,
19021913 " javax" ,
19031914 };
1904- ChromiumStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
19051915 } else if (Language == FormatStyle::LK_JavaScript) {
19061916 ChromiumStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
19071917 ChromiumStyle.AllowShortLoopsOnASingleLine = false ;
@@ -2029,7 +2039,7 @@ FormatStyle getClangFormatStyle() {
20292039FormatStyle getNoStyle () {
20302040 FormatStyle NoStyle = getLLVMStyle ();
20312041 NoStyle.DisableFormat = true ;
2032- NoStyle.SortIncludes = FormatStyle::SI_Never ;
2042+ NoStyle.SortIncludes = {} ;
20332043 NoStyle.SortUsingDeclarations = FormatStyle::SUD_Never;
20342044 return NoStyle;
20352045}
@@ -3220,7 +3230,7 @@ static void sortCppIncludes(const FormatStyle &Style,
32203230 SmallVector<unsigned , 16 > Indices =
32213231 llvm::to_vector<16 >(llvm::seq<unsigned >(0 , Includes.size ()));
32223232
3223- if (Style.SortIncludes == FormatStyle::SI_CaseInsensitive ) {
3233+ if (Style.SortIncludes . Enabled && Style. SortIncludes . IgnoreCase ) {
32243234 stable_sort (Indices, [&](unsigned LHSI, unsigned RHSI) {
32253235 const auto LHSFilenameLower = Includes[LHSI].Filename .lower ();
32263236 const auto RHSFilenameLower = Includes[RHSI].Filename .lower ();
@@ -3595,7 +3605,7 @@ tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
35953605 ArrayRef<tooling::Range> Ranges,
35963606 StringRef FileName, unsigned *Cursor) {
35973607 tooling::Replacements Replaces;
3598- if (!Style.SortIncludes || Style.DisableFormat )
3608+ if (!Style.SortIncludes . Enabled || Style.DisableFormat )
35993609 return Replaces;
36003610 if (isLikelyXml (Code))
36013611 return Replaces;
0 commit comments