diff options
author | Marco Bubke <marco.bubke@qt.io> | 2019-04-10 19:24:36 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2019-04-23 09:09:06 +0000 |
commit | eaaff9da7e93ef1d2218d54071a69ab2dfb79562 (patch) | |
tree | e8c3a8821125114db7090fb7d55cc3e037227649 /src/tools/clangrefactoringbackend/source/symbolindexer.cpp | |
parent | 5a6a9343b586a9718142b86d659ada4852b95ee6 (diff) | |
download | qt-creator-eaaff9da7e93ef1d2218d54071a69ab2dfb79562.tar.gz |
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 <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/tools/clangrefactoringbackend/source/symbolindexer.cpp')
-rw-r--r-- | src/tools/clangrefactoringbackend/source/symbolindexer.cpp | 67 |
1 files changed, 44 insertions, 23 deletions
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<ProjectPartContainer, Utils::SmallStringVector>; - 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<ProjectPartContainer, Utils::SmallStringVector>; + 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<ProjectPartArtefact, Utils::SmallStringVector> builder{ - artefact, artefact.toolChainArguments, InputFileType::Source, {}, {}, pchPath}; + using Builder = CommandLineBuilder<ProjectPartArtefact, Utils::SmallStringVector>; + 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(); } }; |