[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
This commit is contained in:
@@ -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()))
|
||||
|
||||
Reference in New Issue
Block a user