diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2019-08-26 18:29:51 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2019-08-26 18:29:51 +0000 |
commit | 9ef6c49baf45a06d5b54cc9c790c9397e584ba48 (patch) | |
tree | 6401921d31ed1ac3b53fb7de5daa7c09f5911f39 /clang/lib/Frontend/CompilerInstance.cpp | |
parent | 36d1588f017bb6e971cb14cc6e7094c3db9c0436 (diff) | |
download | bcm5719-llvm-9ef6c49baf45a06d5b54cc9c790c9397e584ba48.tar.gz bcm5719-llvm-9ef6c49baf45a06d5b54cc9c790c9397e584ba48.zip |
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/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index f0227d0501c..a7b7114f791 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -833,6 +833,8 @@ bool CompilerInstance::InitializeSourceManager( if (InputFile != "-") { auto FileOrErr = FileMgr.getFileRef(InputFile, /*OpenFile=*/true); if (!FileOrErr) { + // FIXME: include the error in the diagnostic. + consumeError(FileOrErr.takeError()); Diags.Report(diag::err_fe_error_reading) << InputFile; return false; } |