Clang: Don't reparse if the macros haven't changed

We have to extend that to include paths too, which will be happen in a
follow up patch.

Change-Id: I7f8ac663ae8588e647fc6a6b5d689a629a28ef65
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-02-07 16:18:16 +01:00
parent b5c3d5a40d
commit 0172631b48
13 changed files with 140 additions and 21 deletions

View File

@@ -52,31 +52,32 @@ void SymbolIndexer::updateProjectPart(V2::ProjectPartContainer &&projectPart,
{
m_symbolsCollector.clear();
m_symbolsCollector.addFiles(projectPart.sourcePathIds(), projectPart.arguments());
if (compilerMacrosAreDifferent(projectPart)) {
m_symbolsCollector.addFiles(projectPart.sourcePathIds(), projectPart.arguments());
m_symbolsCollector.addUnsavedFiles(generatedFiles);
m_symbolsCollector.addUnsavedFiles(generatedFiles);
m_symbolsCollector.collectSymbols();
m_symbolsCollector.collectSymbols();
Sqlite::ImmediateTransaction transaction{m_transactionInterface};
Sqlite::ImmediateTransaction transaction{m_transactionInterface};
m_symbolStorage.addSymbolsAndSourceLocations(m_symbolsCollector.symbols(),
m_symbolsCollector.sourceLocations());
m_symbolStorage.addSymbolsAndSourceLocations(m_symbolsCollector.symbols(),
m_symbolsCollector.sourceLocations());
m_symbolStorage.insertOrUpdateProjectPart(projectPart.projectPartId(),
projectPart.arguments(),
projectPart.compilerMacros());
m_symbolStorage.updateProjectPartSources(projectPart.projectPartId(),
m_symbolsCollector.sourceFiles());
m_symbolStorage.insertOrUpdateProjectPart(projectPart.projectPartId(),
projectPart.arguments(),
projectPart.compilerMacros());
m_symbolStorage.updateProjectPartSources(projectPart.projectPartId(),
m_symbolsCollector.sourceFiles());
m_symbolStorage.insertOrUpdateUsedMacros(m_symbolsCollector.usedMacros());
m_symbolStorage.insertOrUpdateUsedMacros(m_symbolsCollector.usedMacros());
m_symbolStorage.insertFileStatuses(m_symbolsCollector.fileStatuses());
m_symbolStorage.insertFileStatuses(m_symbolsCollector.fileStatuses());
m_symbolStorage.insertOrUpdateSourceDependencies(m_symbolsCollector.sourceDependencies());
transaction.commit();
m_symbolStorage.insertOrUpdateSourceDependencies(m_symbolsCollector.sourceDependencies());
transaction.commit();
}
}
void SymbolIndexer::pathsWithIdsChanged(const Utils::SmallStringVector &)
@@ -120,4 +121,15 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId)
}
}
bool SymbolIndexer::compilerMacrosAreDifferent(const V2::ProjectPartContainer &projectPart) const
{
const Utils::optional<ProjectPartArtefact> optionalArtefact = m_symbolStorage.fetchProjectPartArtefact(
projectPart.projectPartId());
if (optionalArtefact)
return projectPart.compilerMacros() != optionalArtefact.value().compilerMacros;
return true;
}
} // namespace ClangBackEnd