Skip to content

Commit

Permalink
Adapt rL364464: clang::FrontendAction::Execute returns llvm::Error in…
Browse files Browse the repository at this point in the history
…stead of bool
  • Loading branch information
MaskRay committed Jun 27, 2019
1 parent aab9dd6 commit a858567
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/indexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1270,14 +1270,21 @@ Index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs,

std::unique_ptr<FrontendAction> Action = createIndexingAction(
DataConsumer, IndexOpts, std::make_unique<IndexFrontendAction>(param));

std::string reason;
{
llvm::CrashRecoveryContext CRC;
auto parse = [&]() {
if (!Action->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
return;
#if LLVM_VERSION_MAJOR >= 9 // rL364464
if (llvm::Error E = Action->Execute()) {
reason = llvm::toString(std::move(E));
return;
}
#else
if (!Action->Execute())
return;
#endif
Action->EndSourceFile();
ok = true;
};
Expand All @@ -1287,7 +1294,8 @@ Index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs,
}
}
if (!ok) {
LOG_S(ERROR) << "failed to index " << main;
LOG_S(ERROR) << "failed to index " << main
<< (reason.empty() ? "" : ": " + reason);
return {};
}
for (auto &Buf : Bufs)
Expand Down
7 changes: 7 additions & 0 deletions src/sema_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,15 @@ bool Parse(CompilerInstance &Clang) {
SyntaxOnlyAction Action;
if (!Action.BeginSourceFile(Clang, Clang.getFrontendOpts().Inputs[0]))
return false;
#if LLVM_VERSION_MAJOR >= 9 // rL364464
if (llvm::Error E = Action.Execute()) {
llvm::consumeError(std::move(E));
return false;
}
#else
if (!Action.Execute())
return false;
#endif
Action.EndSourceFile();
return true;
}
Expand Down

0 comments on commit a858567

Please sign in to comment.