Skip to content

Commit

Permalink
[clang] Change FileManager to use llvm::ErrorOr instead of null on fa…
Browse files Browse the repository at this point in the history
…ilure

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
  • Loading branch information
harlanhaskins committed Aug 1, 2019
1 parent a02f857 commit 84586c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Expand Up @@ -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;
}
}
}
}
Expand Down
Expand Up @@ -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))
Expand Down

0 comments on commit 84586c1

Please sign in to comment.