[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
diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp
index d915871..b2276ed 100644
--- a/clang-tools-extra/clangd/ClangdUnit.cpp
+++ b/clang-tools-extra/clangd/ClangdUnit.cpp
@@ -244,6 +244,8 @@
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(