From 2887f5e5a9ced381e684b9b40a9a995c46664cb9 Mon Sep 17 00:00:00 2001 From: Ivan Donchevskii Date: Fri, 15 Feb 2019 16:17:33 +0100 Subject: [PATCH] ClangPchManager: Allow errors in pch-s There are cases when we can't avoid errors when we put all system includes together. This might lead to not having any pch-s which makes the indexing useless (too slow). Change-Id: Icdbfdf916bbd0ed9b6cd18f9c976d3d4efb0e18f Reviewed-by: Marco Bubke --- .../clangpchmanagerbackend/source/generatepchactionfactory.h | 4 ++++ src/tools/clangrefactoringbackend/source/symbolscollector.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/tools/clangpchmanagerbackend/source/generatepchactionfactory.h b/src/tools/clangpchmanagerbackend/source/generatepchactionfactory.h index 50061a9e6cb..2b1f4d036da 100644 --- a/src/tools/clangpchmanagerbackend/source/generatepchactionfactory.h +++ b/src/tools/clangpchmanagerbackend/source/generatepchactionfactory.h @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -44,6 +45,9 @@ public: bool BeginInvocation(clang::CompilerInstance &compilerInstance) override { compilerInstance.getPreprocessorOpts().DisablePCHValidation = true; + compilerInstance.getPreprocessorOpts().AllowPCHWithCompilerErrors = true; + compilerInstance.getLangOpts().DelayedTemplateParsing = true; + compilerInstance.getDiagnosticOpts().ErrorLimit = 0; std::unique_ptr Input = llvm::MemoryBuffer::getMemBuffer(m_fileContent); compilerInstance.getPreprocessorOpts().addRemappedFile(m_filePath, Input.release()); diff --git a/src/tools/clangrefactoringbackend/source/symbolscollector.cpp b/src/tools/clangrefactoringbackend/source/symbolscollector.cpp index 1ceb4a14ce6..188d6fd2077 100644 --- a/src/tools/clangrefactoringbackend/source/symbolscollector.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolscollector.cpp @@ -27,6 +27,7 @@ #include #include +#include namespace ClangBackEnd { @@ -100,6 +101,7 @@ newFrontendActionFactory(Factory *consumerFactory, bool BeginInvocation(clang::CompilerInstance &compilerInstance) override { compilerInstance.getLangOpts().DelayedTemplateParsing = false; + compilerInstance.getPreprocessorOpts().AllowPCHWithCompilerErrors = true; return clang::ASTFrontendAction::BeginInvocation(compilerInstance); }