Author: ibiryukov Date: Mon Jan 29 06:30:28 2018 New Revision: 323652 URL: http://llvm.org/viewvc/llvm-project?rev=323652&view=rev Log: [clangd] Fixed null deference on invalid compile commands.
Code building the AST expected that construction of CompilerInstance always succeeds. This is not the case. Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=323652&r1=323651&r2=323652&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Mon Jan 29 06:30:28 2018 @@ -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( _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits