diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2018-01-29 14:30:28 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2018-01-29 14:30:28 +0000 |
commit | 5e13692d6a43678f5f2bc775ad3e26d5df0036ae (patch) | |
tree | 4b89be73d1fc61c6c6f1470d3e400baca302dac1 /clang-tools-extra/clangd/ClangdUnit.cpp | |
parent | cfe70b9d95113f85f0ce3e5f903886423729a3fc (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.cpp | 2 |
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( |