diff options
author | Marco Bubke <marco.bubke@qt.io> | 2019-04-10 18:43:03 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2019-04-23 09:08:57 +0000 |
commit | 5a6a9343b586a9718142b86d659ada4852b95ee6 (patch) | |
tree | 694ee37aea8cdd6a5bb2ffdd0daa303f8ea48c3f /src/tools | |
parent | 16d5bf0afcee6c080d78219842c88f377c4bc6ce (diff) |
ClangRefactoring: Move command line generation in worker thread
Because we want to retry to index without the PCH we need to move the
command line generation in the worker thread.
Change-Id: Ifd018be277081ee676e5fa51af9e6ee99bbc6724
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/clangrefactoringbackend/source/symbolindexer.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp index cb47b6f5d2..25b3bf41cd 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp @@ -91,11 +91,6 @@ void SymbolIndexer::updateProjectParts(ProjectPartContainers &&projectParts) void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart) { ProjectPartId projectPartId = projectPart.projectPartId; - const FilePath pchPath = m_precompiledHeaderStorage.fetchPrecompiledHeader(projectPartId); - - using Builder = CommandLineBuilder<ProjectPartContainer, Utils::SmallStringVector>; - Builder commandLineBuilder{ - projectPart, projectPart.toolChainArguments, InputFileType::Source, {}, {}, pchPath}; std::vector<SymbolIndexerTask> symbolIndexerTask; symbolIndexerTask.reserve(projectPart.sourcePathIds.size()); @@ -104,9 +99,19 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart) sourcePathId); if (!m_modifiedTimeChecker.isUpToDate(dependentTimeStamps)) { - auto indexing = [arguments = commandLineBuilder.commandLine, sourcePathId, this]( + auto indexing = [projectPart = std::move(projectPart), sourcePathId, this]( SymbolsCollectorInterface &symbolsCollector) { - symbolsCollector.setFile(sourcePathId, arguments); + const FilePath pchPath = m_precompiledHeaderStorage.fetchPrecompiledHeader( + projectPart.projectPartId); + + using Builder = CommandLineBuilder<ProjectPartContainer, Utils::SmallStringVector>; + Builder commandLineBuilder{projectPart, + projectPart.toolChainArguments, + InputFileType::Source, + {}, + {}, + pchPath}; + symbolsCollector.setFile(sourcePathId, commandLineBuilder.commandLine); bool success = symbolsCollector.collectSymbols(); @@ -155,18 +160,20 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId, return; transaction.commit(); - const FilePath pchPath = m_precompiledHeaderStorage.fetchPrecompiledHeader( - optionalArtefact->projectPartId); + ProjectPartId projectPartId = optionalArtefact->projectPartId; + SourceTimeStamps dependentTimeStamps = m_symbolStorage.fetchIncludedIndexingTimeStamps(filePathId); - const ProjectPartArtefact &artefact = *optionalArtefact; + auto indexing = [optionalArtefact = std::move(optionalArtefact), filePathId, this]( + SymbolsCollectorInterface &symbolsCollector) { + const FilePath pchPath = m_precompiledHeaderStorage.fetchPrecompiledHeader( + optionalArtefact->projectPartId); + const ProjectPartArtefact &artefact = *optionalArtefact; - CommandLineBuilder<ProjectPartArtefact, Utils::SmallStringVector> builder{ - artefact, artefact.toolChainArguments, InputFileType::Source, {}, {}, pchPath}; + CommandLineBuilder<ProjectPartArtefact, Utils::SmallStringVector> builder{ + artefact, artefact.toolChainArguments, InputFileType::Source, {}, {}, pchPath}; - auto indexing = [arguments = builder.commandLine, filePathId, this]( - SymbolsCollectorInterface &symbolsCollector) { - symbolsCollector.setFile(filePathId, arguments); + symbolsCollector.setFile(filePathId, builder.commandLine); bool success = symbolsCollector.collectSymbols(); @@ -179,7 +186,7 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId, } }; - symbolIndexerTask.emplace_back(filePathId, optionalArtefact->projectPartId, std::move(indexing)); + symbolIndexerTask.emplace_back(filePathId, projectPartId, std::move(indexing)); } bool SymbolIndexer::compilerMacrosOrIncludeSearchPathsAreDifferent( |