[clang] [clang] NFCI: Make `ModuleFile::File` non-optional (PR #74892)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 8 14:45:17 PST 2023


================
@@ -441,22 +434,19 @@ void ModuleManager::visit(llvm::function_ref<bool(ModuleFile &M)> Visitor,
 bool ModuleManager::lookupModuleFile(StringRef FileName, off_t ExpectedSize,
                                      time_t ExpectedModTime,
                                      OptionalFileEntryRef &File) {
-  File = std::nullopt;
-  if (FileName == "-")
+  if (FileName == "-") {
+    File = expectedToOptional(FileMgr.getSTDIN());
     return false;
+  }
 
   // Open the file immediately to ensure there is no race between stat'ing and
   // opening the file.
-  OptionalFileEntryRef FileOrErr =
-      expectedToOptional(FileMgr.getFileRef(FileName, /*OpenFile=*/true,
-                                            /*CacheFailure=*/false));
-  if (!FileOrErr)
-    return false;
-
-  File = *FileOrErr;
+  File = expectedToOptional(FileMgr.getFileRef(FileName, /*OpenFile=*/true,
----------------
jansvoboda11 wrote:

I guess I could've replace this with `getOptionalFileRef()` while I'm touching the line.

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


More information about the cfe-commits mailing list