mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 09:05:10 +00:00
sema_manager: Use llvm::CrashRecoveryContext
This commit is contained in:
parent
c018bce9af
commit
80d06eb476
@ -327,19 +327,26 @@ buildCompilerInstance(Session &session, std::unique_ptr<CompilerInvocation> ci,
|
|||||||
|
|
||||||
bool parse(CompilerInstance &clang) {
|
bool parse(CompilerInstance &clang) {
|
||||||
SyntaxOnlyAction action;
|
SyntaxOnlyAction action;
|
||||||
|
llvm::CrashRecoveryContext crc;
|
||||||
|
bool ok = false;
|
||||||
|
auto run = [&]() {
|
||||||
if (!action.BeginSourceFile(clang, clang.getFrontendOpts().Inputs[0]))
|
if (!action.BeginSourceFile(clang, clang.getFrontendOpts().Inputs[0]))
|
||||||
return false;
|
return;
|
||||||
#if LLVM_VERSION_MAJOR >= 9 // rL364464
|
#if LLVM_VERSION_MAJOR >= 9 // rL364464
|
||||||
if (llvm::Error e = action.Execute()) {
|
if (llvm::Error e = action.Execute()) {
|
||||||
llvm::consumeError(std::move(e));
|
llvm::consumeError(std::move(e));
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (!action.Execute())
|
if (!action.Execute())
|
||||||
return false;
|
return;
|
||||||
#endif
|
#endif
|
||||||
action.EndSourceFile();
|
action.EndSourceFile();
|
||||||
return true;
|
ok = true;
|
||||||
|
};
|
||||||
|
if (!crc.RunSafely(run))
|
||||||
|
LOG_S(ERROR) << "clang crashed";
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildPreamble(Session &session, CompilerInvocation &ci,
|
void buildPreamble(Session &session, CompilerInvocation &ci,
|
||||||
|
Loading…
Reference in New Issue
Block a user