================
@@ -3683,6 +3688,32 @@ static void sortCppIncludes(const FormatStyle &Style,
                                ? &StringRef::compare_numeric
                                : &StringRef::compare;
 
+      while (Style.SortIncludes.FilesBeforeFolders) {
+        auto [LHead, LTail] = LHSStem.split('/');
+        auto [RHead, RTail] = RHSStem.split('/');
+
+        bool LIsFile = LTail.empty();
+        bool RIsFile = RTail.empty();
+
+        // A file at this level sorts before a subdirectory at this level.
+        if (LIsFile != RIsFile)
+          return LIsFile;
+
+        // Both are leaf filenames — they are equal at this level, so we
+        // can break out of the loop and compare the full filenames later.
+        if (LIsFile)
+          break;
+
+        // Both are directory components at this level — compare them.
+        int Cmp = std::invoke(Compare, LHead, RHead);
----------------
Shiakaron wrote:

You were right. Addressed, but haven't seen how I could do so by 'injecting 
`Compare`'. I also added a UT to cover this 

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

Reply via email to