summaryrefslogtreecommitdiff
path: root/clang-tools-extra/clangd/ClangdUnit.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-01-29 14:30:28 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-01-29 14:30:28 +0000
commit5e13692d6a43678f5f2bc775ad3e26d5df0036ae (patch)
tree4b89be73d1fc61c6c6f1470d3e400baca302dac1 /clang-tools-extra/clangd/ClangdUnit.cpp
parentcfe70b9d95113f85f0ce3e5f903886423729a3fc (diff)
[clangd] Fixed null deference on invalid compile commands.
Code building the AST expected that construction of CompilerInstance always succeeds. This is not the case.
Diffstat (limited to 'clang-tools-extra/clangd/ClangdUnit.cpp')
-rw-r--r--clang-tools-extra/clangd/ClangdUnit.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp
index d915871a4ef..b2276edc983 100644
--- a/clang-tools-extra/clangd/ClangdUnit.cpp
+++ b/clang-tools-extra/clangd/ClangdUnit.cpp
@@ -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(