[clangd] Fixed null deference on invalid compile commands.

Code building the AST expected that construction of CompilerInstance
always succeeds. This is not the case.

llvm-svn: 323652
This commit is contained in:
Ilya Biryukov 2018-01-29 14:30:28 +00:00
parent 4f321aef74
commit cec6335f35

View File

@ -244,6 +244,8 @@ ParsedAST::Build(const Context &Ctx,
auto Clang = prepareCompilerInstance(
std::move(CI), PreamblePCH, std::move(Buffer), std::move(PCHs),
std::move(VFS), /*ref*/ UnitDiagsConsumer);
if (!Clang)
return llvm::None;
// Recover resources if we crash before exiting this method.
llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance> CICleanup(