Skip to content

Commit a858567

Browse files
committed
Adapt rL364464: clang::FrontendAction::Execute returns llvm::Error instead of bool
1 parent aab9dd6 commit a858567

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/indexer.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,14 +1270,21 @@ Index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs,
12701270

12711271
std::unique_ptr<FrontendAction> Action = createIndexingAction(
12721272
DataConsumer, IndexOpts, std::make_unique<IndexFrontendAction>(param));
1273-
1273+
std::string reason;
12741274
{
12751275
llvm::CrashRecoveryContext CRC;
12761276
auto parse = [&]() {
12771277
if (!Action->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
12781278
return;
1279+
#if LLVM_VERSION_MAJOR >= 9 // rL364464
1280+
if (llvm::Error E = Action->Execute()) {
1281+
reason = llvm::toString(std::move(E));
1282+
return;
1283+
}
1284+
#else
12791285
if (!Action->Execute())
12801286
return;
1287+
#endif
12811288
Action->EndSourceFile();
12821289
ok = true;
12831290
};
@@ -1287,7 +1294,8 @@ Index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs,
12871294
}
12881295
}
12891296
if (!ok) {
1290-
LOG_S(ERROR) << "failed to index " << main;
1297+
LOG_S(ERROR) << "failed to index " << main
1298+
<< (reason.empty() ? "" : ": " + reason);
12911299
return {};
12921300
}
12931301
for (auto &Buf : Bufs)

src/sema_manager.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,15 @@ bool Parse(CompilerInstance &Clang) {
324324
SyntaxOnlyAction Action;
325325
if (!Action.BeginSourceFile(Clang, Clang.getFrontendOpts().Inputs[0]))
326326
return false;
327+
#if LLVM_VERSION_MAJOR >= 9 // rL364464
328+
if (llvm::Error E = Action.Execute()) {
329+
llvm::consumeError(std::move(E));
330+
return false;
331+
}
332+
#else
327333
if (!Action.Execute())
328334
return false;
335+
#endif
329336
Action.EndSourceFile();
330337
return true;
331338
}

0 commit comments

Comments
 (0)