aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/HeaderMap.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2019-08-26 18:29:51 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2019-08-26 18:29:51 +0000
commit9ef6c49baf45a06d5b54cc9c790c9397e584ba48 (patch)
tree6401921d31ed1ac3b53fb7de5daa7c09f5911f39 /clang/lib/Lex/HeaderMap.cpp
parent36d1588f017bb6e971cb14cc6e7094c3db9c0436 (diff)
downloadllvm-9ef6c49baf45a06d5b54cc9c790c9397e584ba48.zip
llvm-9ef6c49baf45a06d5b54cc9c790c9397e584ba48.tar.gz
llvm-9ef6c49baf45a06d5b54cc9c790c9397e584ba48.tar.bz2
FileManager: Use llvm::Expected in new getFileRef API
`FileManager::getFileRef` is a modern API which we expect to convert to over time. We should modernize the error handling as well, using `llvm::Expected` instead of `llvm::ErrorOr`, to help clients that care about errors to ensure nothing is missed. However, not all clients care. I've also added another path for those that don't: - `FileEntryRef` is now copy- and move-assignable (using a pointer instead of a reference). - `FileManager::getOptionalFileRef` returns an `llvm::Optional` instead of `llvm::Expected`. - Added an `llvm::expectedToOptional` utility in case this is useful elsewhere. https://reviews.llvm.org/D66705 llvm-svn: 369943
Diffstat (limited to 'clang/lib/Lex/HeaderMap.cpp')
-rw-r--r--clang/lib/Lex/HeaderMap.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/clang/lib/Lex/HeaderMap.cpp b/clang/lib/Lex/HeaderMap.cpp
index 1c7fb1a..d44ef29c 100644
--- a/clang/lib/Lex/HeaderMap.cpp
+++ b/clang/lib/Lex/HeaderMap.cpp
@@ -204,9 +204,7 @@ Optional<FileEntryRef> HeaderMap::LookupFile(StringRef Filename,
if (Dest.empty())
return None;
- if (auto File = FM.getFileRef(Dest))
- return *File;
- return None;
+ return FM.getOptionalFileRef(Dest);
}
StringRef HeaderMapImpl::lookupFilename(StringRef Filename,