From eaaff9da7e93ef1d2218d54071a69ab2dfb79562 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 10 Apr 2019 19:24:36 +0200 Subject: Clang: Reindex without PCHs if error are occurring If an occurs we first reindex with the system PCH only and if it is still occurring we are indexing without any PCH. Task-number: QTCREATORBUG-22011 Change-Id: I815ee3abe7829aaeb191d985cd045bac35015893 Reviewed-by: Ivan Donchevskii --- .../source/symbolindexer.cpp | 67 ++++++++++++++-------- 1 file changed, 44 insertions(+), 23 deletions(-) (limited to 'src/tools/clangrefactoringbackend') diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp index 25b3bf41cd..109e6c5e80 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp @@ -101,26 +101,36 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart) if (!m_modifiedTimeChecker.isUpToDate(dependentTimeStamps)) { auto indexing = [projectPart = std::move(projectPart), sourcePathId, this]( SymbolsCollectorInterface &symbolsCollector) { - const FilePath pchPath = m_precompiledHeaderStorage.fetchPrecompiledHeader( - projectPart.projectPartId); - - using Builder = CommandLineBuilder; - Builder commandLineBuilder{projectPart, - projectPart.toolChainArguments, - InputFileType::Source, - {}, - {}, - pchPath}; - symbolsCollector.setFile(sourcePathId, commandLineBuilder.commandLine); - - bool success = symbolsCollector.collectSymbols(); - - if (success) { + auto collect = [&](const FilePath &pchPath) { + using Builder = CommandLineBuilder; + Builder commandLineBuilder{projectPart, + projectPart.toolChainArguments, + InputFileType::Source, + {}, + {}, + pchPath}; + symbolsCollector.setFile(sourcePathId, commandLineBuilder.commandLine); + + return symbolsCollector.collectSymbols(); + }; + + auto store = [&] { Sqlite::ImmediateTransaction transaction{m_transactionInterface}; m_symbolStorage.insertOrUpdateIndexingTimeStamps(symbolsCollector.fileStatuses()); m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(), symbolsCollector.sourceLocations()); transaction.commit(); + }; + + const PchPaths pchPaths = m_precompiledHeaderStorage.fetchPrecompiledHeaders( + projectPart.projectPartId); + + if (pchPaths.projectPchPath.size() && collect(pchPaths.projectPchPath)) { + store(); + } else if (pchPaths.systemPchPath.size() && collect(pchPaths.systemPchPath)) { + store(); + } else if (collect({})) { + store(); } }; @@ -166,23 +176,34 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId, auto indexing = [optionalArtefact = std::move(optionalArtefact), filePathId, this]( SymbolsCollectorInterface &symbolsCollector) { - const FilePath pchPath = m_precompiledHeaderStorage.fetchPrecompiledHeader( - optionalArtefact->projectPartId); - const ProjectPartArtefact &artefact = *optionalArtefact; + auto collect = [&](const FilePath &pchPath) { + const ProjectPartArtefact &artefact = *optionalArtefact; - CommandLineBuilder builder{ - artefact, artefact.toolChainArguments, InputFileType::Source, {}, {}, pchPath}; + using Builder = CommandLineBuilder; + Builder builder{artefact, artefact.toolChainArguments, InputFileType::Source, {}, {}, pchPath}; - symbolsCollector.setFile(filePathId, builder.commandLine); + symbolsCollector.setFile(filePathId, builder.commandLine); - bool success = symbolsCollector.collectSymbols(); + return symbolsCollector.collectSymbols(); + }; - if (success) { + auto store = [&] { Sqlite::ImmediateTransaction transaction{m_transactionInterface}; m_symbolStorage.insertOrUpdateIndexingTimeStamps(symbolsCollector.fileStatuses()); m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(), symbolsCollector.sourceLocations()); transaction.commit(); + }; + + const PchPaths pchPaths = m_precompiledHeaderStorage.fetchPrecompiledHeaders( + optionalArtefact->projectPartId); + + if (pchPaths.projectPchPath.size() && collect(pchPaths.projectPchPath)) { + store(); + } else if (pchPaths.systemPchPath.size() && collect(pchPaths.systemPchPath)) { + store(); + } else if (collect({})) { + store(); } }; -- cgit v1.2.1