summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarlan Haskins <harlan@harlanhaskins.com>2019-08-01 21:32:04 +0000
committerHarlan Haskins <harlan@harlanhaskins.com>2019-08-01 21:32:04 +0000
commit84586c1423aae1ca12f5203215b0eeb7c148ed6d (patch)
tree651f0aab7749c7811172b0a0e9887332981b24c3
parenta02f85768d2d1a77c7735ddd43226e1be51f3730 (diff)
downloadbcm5719-llvm-84586c1423aae1ca12f5203215b0eeb7c148ed6d.tar.gz
bcm5719-llvm-84586c1423aae1ca12f5203215b0eeb7c148ed6d.zip
[clang] Change FileManager to use llvm::ErrorOr instead of null on failure
Summary: Currently, clang's FileManager uses NULL as an indicator that a particular file did not exist, but would not propagate errors like permission issues. Instead, teach FileManager to use llvm::ErrorOr internally and return rich errors for failures. Reviewers: arphaman, bruno, martong, shafik Subscribers: nemanjai, kbarton, MaskRay, jkorous, dexonsmith, kadircet, jsji, cfe-commits, lldb-commits Tags: #clang, #lldb Differential Revision: https://reviews.llvm.org/D65534 llvm-svn: 367618
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp11
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp4
2 files changed, 9 insertions, 6 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index c9226ba5e92..01e768a2ccf 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -908,10 +908,13 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
if (file.Write(expr_text, bytes_written).Success()) {
if (bytes_written == expr_text_len) {
file.Close();
- source_mgr.setMainFileID(source_mgr.createFileID(
- m_compiler->getFileManager().getFile(result_path),
- SourceLocation(), SrcMgr::C_User));
- created_main_file = true;
+ if (auto fileEntry =
+ m_compiler->getFileManager().getFile(result_path)) {
+ source_mgr.setMainFileID(source_mgr.createFileID(
+ *fileEntry,
+ SourceLocation(), SrcMgr::C_User));
+ created_main_file = true;
+ }
}
}
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index deecb66a24f..f22c7f515ab 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -247,11 +247,11 @@ bool ClangModulesDeclVendorImpl::AddModule(const SourceModule &module,
bool is_system = true;
bool is_framework = false;
- auto *dir =
+ auto dir =
HS.getFileMgr().getDirectory(module.search_path.GetStringRef());
if (!dir)
return error();
- auto *file = HS.lookupModuleMapFile(dir, is_framework);
+ auto *file = HS.lookupModuleMapFile(*dir, is_framework);
if (!file)
return error();
if (!HS.loadModuleMapFile(file, is_system))
OpenPOWER on IntegriCloud