================
@@ -3647,6 +3656,24 @@ static void sortCppIncludes(const FormatStyle &Style,
         LHSFilenameLower = Includes[LHSI].Filename.lower();
         RHSFilenameLower = Includes[RHSI].Filename.lower();
       }
+      if (Style.SortIncludes.Natural) {
+        if (Includes[LHSI].Priority != Includes[RHSI].Priority)
+          return Includes[LHSI].Priority < Includes[RHSI].Priority;
+        if (Style.SortIncludes.IgnoreCase) {
+          if (int Cmp = StringRef(LHSStemLower).compare_numeric(RHSStemLower))
+            return Cmp < 0;
+        }
+        if (int Cmp = StringRef(LHSStem).compare_numeric(RHSStem))
+          return Cmp < 0;
+        if (Style.SortIncludes.IgnoreCase) {
+          if (int Cmp = StringRef(LHSFilenameLower)
+                            .compare_numeric(RHSFilenameLower)) {
+            return Cmp < 0;
+          }
+        }
+        return StringRef(Includes[LHSI].Filename)
+                   .compare_numeric(Includes[RHSI].Filename) < 0;
+      }
       return std::tie(Includes[LHSI].Priority, LHSStemLower, LHSStem,
                       LHSFilenameLower, Includes[LHSI].Filename) <
              std::tie(Includes[RHSI].Priority, RHSStemLower, RHSStem,
----------------
HazardyKnusperkeks wrote:

Extract the Priority, we can handle that even before all the stem computation.
I think it would be nice, if you can store the compare function in a variable 
and after that do the same thing for both paths.

https://github.com/llvm/llvm-project/pull/210788
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to