forked from qt-creator/qt-creator
Clang: Improve dependency building
We want to use the cached values in the database because it is faster than to parse the the files again. Task-number: QTCREATORBUG-22035 Change-Id: I7ada7073887b1d89a06332fdb617701cb69ccd68 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -36,15 +36,8 @@ namespace ClangBackEnd {
|
||||
class FileStatus
|
||||
{
|
||||
public:
|
||||
FileStatus(FilePathId filePathId,
|
||||
off_t size,
|
||||
std::time_t lastModified,
|
||||
bool isInPrecompiledHeader)
|
||||
: filePathId(filePathId),
|
||||
size(size),
|
||||
lastModified(lastModified),
|
||||
isInPrecompiledHeader(isInPrecompiledHeader)
|
||||
{}
|
||||
FileStatus(FilePathId filePathId, off_t size, std::time_t lastModified)
|
||||
: filePathId(filePathId), size(size), lastModified(lastModified) {}
|
||||
|
||||
friend
|
||||
bool operator==(const FileStatus &first, const FileStatus &second)
|
||||
@@ -64,7 +57,6 @@ public:
|
||||
FilePathId filePathId;
|
||||
off_t size;
|
||||
std::time_t lastModified;
|
||||
bool isInPrecompiledHeader;
|
||||
};
|
||||
|
||||
using FileStatuses = std::vector<FileStatus>;
|
||||
|
||||
@@ -120,8 +120,7 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
|
||||
std::vector<SymbolIndexerTask> symbolIndexerTask;
|
||||
symbolIndexerTask.reserve(projectPart.sourcePathIds.size());
|
||||
for (FilePathId sourcePathId : projectPart.sourcePathIds) {
|
||||
auto indexing = [projectPartId,
|
||||
arguments = commandLineBuilder.commandLine,
|
||||
auto indexing = [arguments = commandLineBuilder.commandLine,
|
||||
sourcePathId,
|
||||
this](SymbolsCollectorInterface &symbolsCollector) {
|
||||
symbolsCollector.setFile(sourcePathId, arguments);
|
||||
@@ -134,12 +133,9 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
|
||||
m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(),
|
||||
symbolsCollector.sourceLocations());
|
||||
|
||||
m_symbolStorage.updateProjectPartSources(projectPartId,
|
||||
symbolsCollector.sourceFiles());
|
||||
|
||||
m_buildDependencyStorage.insertOrUpdateUsedMacros(symbolsCollector.usedMacros());
|
||||
|
||||
m_buildDependencyStorage.insertFileStatuses(symbolsCollector.fileStatuses());
|
||||
m_buildDependencyStorage.insertOrUpdateFileStatuses(symbolsCollector.fileStatuses());
|
||||
|
||||
m_buildDependencyStorage.insertOrUpdateSourceDependencies(
|
||||
symbolsCollector.sourceDependencies());
|
||||
@@ -193,10 +189,8 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId,
|
||||
CommandLineBuilder<ProjectPartArtefact, Utils::SmallStringVector>
|
||||
builder{artefact, artefact.toolChainArguments, InputFileType::Source, {}, {}, pchPath};
|
||||
|
||||
auto indexing = [projectPartId = artefact.projectPartId,
|
||||
arguments = builder.commandLine,
|
||||
filePathId,
|
||||
this](SymbolsCollectorInterface &symbolsCollector) {
|
||||
auto indexing = [arguments = builder.commandLine, filePathId, this](
|
||||
SymbolsCollectorInterface &symbolsCollector) {
|
||||
symbolsCollector.setFile(filePathId, arguments);
|
||||
|
||||
bool success = symbolsCollector.collectSymbols();
|
||||
@@ -207,11 +201,9 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId,
|
||||
m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(),
|
||||
symbolsCollector.sourceLocations());
|
||||
|
||||
m_symbolStorage.updateProjectPartSources(projectPartId, symbolsCollector.sourceFiles());
|
||||
|
||||
m_buildDependencyStorage.insertOrUpdateUsedMacros(symbolsCollector.usedMacros());
|
||||
|
||||
m_buildDependencyStorage.insertFileStatuses(symbolsCollector.fileStatuses());
|
||||
m_buildDependencyStorage.insertOrUpdateFileStatuses(symbolsCollector.fileStatuses());
|
||||
|
||||
m_buildDependencyStorage.insertOrUpdateSourceDependencies(
|
||||
symbolsCollector.sourceDependencies());
|
||||
|
||||
@@ -112,17 +112,6 @@ public:
|
||||
return statement.template value<ProjectPartArtefact, 8>(projectPartName);
|
||||
}
|
||||
|
||||
void updateProjectPartSources(int projectPartId,
|
||||
const FilePathIds &sourceFilePathIds) override
|
||||
{
|
||||
WriteStatement &deleteStatement = m_deleteAllProjectPartsSourcesWithProjectPartIdStatement;
|
||||
deleteStatement.write(projectPartId);
|
||||
|
||||
WriteStatement &insertStatement = m_insertProjectPartSourcesStatement;
|
||||
for (const FilePathId &sourceFilePathId : sourceFilePathIds)
|
||||
insertStatement.write(projectPartId, sourceFilePathId.filePathId);
|
||||
}
|
||||
|
||||
static Utils::SmallString toJson(const Utils::SmallStringVector &strings)
|
||||
{
|
||||
QJsonDocument document;
|
||||
@@ -322,14 +311,7 @@ public:
|
||||
"SELECT projectPartId FROM projectParts WHERE projectPartName = ?",
|
||||
m_database
|
||||
};
|
||||
WriteStatement m_deleteAllProjectPartsSourcesWithProjectPartIdStatement{
|
||||
"DELETE FROM projectPartsSources WHERE projectPartId = ?",
|
||||
m_database
|
||||
};
|
||||
WriteStatement m_insertProjectPartSourcesStatement{
|
||||
"INSERT INTO projectPartsSources(projectPartId, sourceId) VALUES (?,?)",
|
||||
m_database
|
||||
};
|
||||
|
||||
mutable ReadStatement m_getCompileArgumentsForFileIdStatement{
|
||||
"SELECT toolChainArguments FROM projectParts WHERE projectPartId = (SELECT projectPartId "
|
||||
"FROM projectPartsSources WHERE sourceId = ?)",
|
||||
|
||||
@@ -61,7 +61,6 @@ public:
|
||||
Utils::LanguageVersion languageVersion,
|
||||
Utils::LanguageExtension languageExtension)
|
||||
= 0;
|
||||
virtual void updateProjectPartSources(int projectPartId, const FilePathIds &sourceFilePathIds) = 0;
|
||||
virtual Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(
|
||||
FilePathId sourceId) const = 0;
|
||||
virtual Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(
|
||||
|
||||
Reference in New Issue
Block a user