[llvm] [CAS] Fix wrong usage of `llvm::sort()` in UnifiedOnDiskCache (PR #166963)

Steven Wu via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 7 08:06:11 PST 2025


https://github.com/cachemeifyoucan created https://github.com/llvm/llvm-project/pull/166963

Fix compare function in getAllDBDirs(). The compare function in sort
should be strictly less than operator.


>From 373e70dfa17713f6b24ef066fdc5104ad535b8d8 Mon Sep 17 00:00:00 2001
From: Steven Wu <stevenwu at apple.com>
Date: Fri, 7 Nov 2025 08:06:01 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7
---
 llvm/lib/CAS/UnifiedOnDiskCache.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/CAS/UnifiedOnDiskCache.cpp b/llvm/lib/CAS/UnifiedOnDiskCache.cpp
index ae9d818241f4b..7b790bb005ce9 100644
--- a/llvm/lib/CAS/UnifiedOnDiskCache.cpp
+++ b/llvm/lib/CAS/UnifiedOnDiskCache.cpp
@@ -174,7 +174,7 @@ getAllDBDirs(StringRef Path, bool IncludeCorrupt = false) {
     return createFileError(Path, EC);
 
   llvm::sort(FoundDBDirs, [](const DBDir &LHS, const DBDir &RHS) -> bool {
-    return LHS.Order <= RHS.Order;
+    return LHS.Order < RHS.Order;
   });
 
   SmallVector<std::string, 4> DBDirs;



More information about the llvm-commits mailing list