================
@@ -3632,13 +3641,17 @@ static void sortCppIncludes(const FormatStyle &Style,
 
   if (Style.SortIncludes.Enabled) {
     stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
+      if (Includes[LHSI].Priority != Includes[RHSI].Priority)
+        return Includes[LHSI].Priority < Includes[RHSI].Priority;
+
       SmallString<128> LHSStem, RHSStem;
       if (Style.SortIncludes.IgnoreExtension) {
         LHSStem = Includes[LHSI].Filename;
         RHSStem = Includes[RHSI].Filename;
         llvm::sys::path::replace_extension(LHSStem, "");
         llvm::sys::path::replace_extension(RHSStem, "");
       }
+
       std::string LHSStemLower, RHSStemLower;
       std::string LHSFilenameLower, RHSFilenameLower;
       if (Style.SortIncludes.IgnoreCase) {
----------------
HazardyKnusperkeks wrote:

While at it, maybe just add two StringRefs initialized to the LHS rsp. RHS 
Filename and reassign the StringRef inside this if. That should simplify the 
remaining code. (And also not compare two empty strings in case of case 
sensitive sorting.)

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