From 9f151df17800e1668c32e5314a290ae94c8f2dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Duncan=20P=2E=20N=2E=20Exon=C2=A0Smith?= Date: Tue, 20 Oct 2020 18:11:52 -0400 Subject: Change Module::ASTFile and ModuleFile::File => Optional, NFC Change `Module::ASTFile` and `ModuleFile::File` to use `Optional` instead of `const FileEntry *`. One of many steps toward removing `FileEntry::getName`. Differential Revision: https://reviews.llvm.org/D89836 --- clang/lib/Serialization/ModuleManager.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'clang/lib/Serialization/ModuleManager.cpp') diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp index 2c65c0b..40ffa6c 100644 --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -112,7 +112,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type, // Look for the file entry. This only fails if the expected size or // modification time differ. - const FileEntry *Entry; + OptionalFileEntryRefDegradesToFileEntryPtr Entry; if (Type == MK_ExplicitModule || Type == MK_PrebuiltModule) { // If we're not expecting to pull this file out of the module cache, it // might have a different mtime due to being moved across filesystems in @@ -288,7 +288,7 @@ void ModuleManager::removeModules(ModuleIterator First, ModuleMap *modMap) { if (modMap) { StringRef ModuleName = victim->ModuleName; if (Module *mod = modMap->findModule(ModuleName)) { - mod->setASTFile(nullptr); + mod->setASTFile(None); } } } @@ -458,18 +458,18 @@ void ModuleManager::visit(llvm::function_ref Visitor, returnVisitState(State); } -bool ModuleManager::lookupModuleFile(StringRef FileName, - off_t ExpectedSize, +bool ModuleManager::lookupModuleFile(StringRef FileName, off_t ExpectedSize, time_t ExpectedModTime, - const FileEntry *&File) { - File = nullptr; + Optional &File) { + File = None; if (FileName == "-") return false; // Open the file immediately to ensure there is no race between stat'ing and // opening the file. - auto FileOrErr = FileMgr.getFile(FileName, /*OpenFile=*/true, - /*CacheFailure=*/false); + Optional FileOrErr = + expectedToOptional(FileMgr.getFileRef(FileName, /*OpenFile=*/true, + /*CacheFailure=*/false)); if (!FileOrErr) return false; -- cgit v1.1