[llvm] [ThinLTO] Replace `ErrorOr` with `Expected` (PR #80088)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 17:16:51 PST 2024


================
@@ -397,19 +397,22 @@ class ModuleCacheEntry {
   // Access the path to this entry in the cache.
   StringRef getEntryPath() { return EntryPath; }
 
-  // Try loading the buffer for this cache entry.
-  ErrorOr<std::unique_ptr<MemoryBuffer>> tryLoadingBuffer() {
-    if (EntryPath.empty())
-      return std::error_code();
+  /// Try loading the buffer for this cache entry.
+  ///
+  /// \returns The buffer on cache hit, null on cache miss, or an error when
+  /// unable to load the cache contents.
+  Expected<std::unique_ptr<MemoryBuffer>> tryLoadingBuffer() {
+    if (EntryPath.empty() || !sys::fs::exists(EntryPath))
----------------
MaskRay wrote:

Does the extra `!sys::fs::exists(EntryPath)` cause any behavior change worth testing?

https://github.com/llvm/llvm-project/pull/80088


More information about the llvm-commits mailing list