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 <marco.bubke@qt.io>
This commit is contained in:
Ivan Donchevskii
2019-02-15 16:17:33 +01:00
parent 35c9e65d3e
commit 2887f5e5a9
2 changed files with 6 additions and 0 deletions

View File

@@ -27,6 +27,7 @@
#include <clang/Tooling/Tooling.h>
#include <clang/Basic/DiagnosticOptions.h>
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/FrontendActions.h>
#include <clang/Lex/PreprocessorOptions.h>
@@ -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<llvm::MemoryBuffer> Input = llvm::MemoryBuffer::getMemBuffer(m_fileContent);
compilerInstance.getPreprocessorOpts().addRemappedFile(m_filePath, Input.release());

View File

@@ -27,6 +27,7 @@
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/FrontendActions.h>
#include <clang/Lex/PreprocessorOptions.h>
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);
}