From 9ef6c49baf45a06d5b54cc9c790c9397e584ba48 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 26 Aug 2019 18:29:51 +0000 Subject: 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 --- clang/lib/Lex/HeaderMap.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'clang/lib/Lex/HeaderMap.cpp') 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 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, -- cgit v1.1