diff options
author | Harlan Haskins <harlan@harlanhaskins.com> | 2019-08-01 21:31:56 +0000 |
---|---|---|
committer | Harlan Haskins <harlan@harlanhaskins.com> | 2019-08-01 21:31:56 +0000 |
commit | 8d323d150610bed1feeb79d7a29c9958a4c8bcac (patch) | |
tree | 166514f9a8bba05ea1504afab5c319975a57675d /clang/lib/Serialization/ModuleManager.cpp | |
parent | 461f0722dd26487c1faa497ba37aabed1477a561 (diff) | |
download | llvm-8d323d150610bed1feeb79d7a29c9958a4c8bcac.zip llvm-8d323d150610bed1feeb79d7a29c9958a4c8bcac.tar.gz llvm-8d323d150610bed1feeb79d7a29c9958a4c8bcac.tar.bz2 |
[clang] Adopt new FileManager error-returning APIs
Update the callers of FileManager::getFile and FileManager::getDirectory to handle the new llvm::ErrorOr-returning methods.
Signed-off-by: Harlan Haskins <harlan@apple.com>
llvm-svn: 367616
Diffstat (limited to 'clang/lib/Serialization/ModuleManager.cpp')
-rw-r--r-- | clang/lib/Serialization/ModuleManager.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp index 6ae0c4f..fb8f1d9 100644 --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -42,10 +42,10 @@ using namespace clang; using namespace serialization; ModuleFile *ModuleManager::lookupByFileName(StringRef Name) const { - const FileEntry *Entry = FileMgr.getFile(Name, /*OpenFile=*/false, - /*CacheFailure=*/false); + auto Entry = FileMgr.getFile(Name, /*OpenFile=*/false, + /*CacheFailure=*/false); if (Entry) - return lookup(Entry); + return lookup(*Entry); return nullptr; } @@ -68,9 +68,11 @@ ModuleFile *ModuleManager::lookup(const FileEntry *File) const { std::unique_ptr<llvm::MemoryBuffer> ModuleManager::lookupBuffer(StringRef Name) { - const FileEntry *Entry = FileMgr.getFile(Name, /*OpenFile=*/false, - /*CacheFailure=*/false); - return std::move(InMemoryBuffers[Entry]); + auto Entry = FileMgr.getFile(Name, /*OpenFile=*/false, + /*CacheFailure=*/false); + if (!Entry) + return nullptr; + return std::move(InMemoryBuffers[*Entry]); } static bool checkSignature(ASTFileSignature Signature, @@ -447,9 +449,13 @@ bool ModuleManager::lookupModuleFile(StringRef FileName, // Open the file immediately to ensure there is no race between stat'ing and // opening the file. - File = FileMgr.getFile(FileName, /*OpenFile=*/true, /*CacheFailure=*/false); - if (!File) + auto FileOrErr = FileMgr.getFile(FileName, /*OpenFile=*/true, + /*CacheFailure=*/false); + if (!FileOrErr) { + File = nullptr; return false; + } + File = *FileOrErr; if ((ExpectedSize && ExpectedSize != File->getSize()) || (ExpectedModTime && ExpectedModTime != File->getModificationTime())) |