diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp index 0789ace0c81..5a9fcdbbd31 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp @@ -323,14 +323,16 @@ static AnalyzeUnits unitsToAnalyzeFromCompilerCallData( AnalyzeUnits unitsToAnalyze; - QHashIterator > it(compilerCallData); - while (it.hasNext()) { - it.next(); - const QString file = it.key(); - const QList compilerCalls = it.value(); - foreach (const QStringList &options, compilerCalls) { - const QStringList arguments = tweakedArguments(file, options, extraParams); - unitsToAnalyze << AnalyzeUnit(file, arguments); + foreach (const ProjectInfo::CompilerCallGroup &compilerCallGroup, compilerCallData) { + QHashIterator > it(compilerCallGroup.callsPerSourceFile); + while (it.hasNext()) { + it.next(); + const QString file = it.key(); + const QList compilerCalls = it.value(); + foreach (const QStringList &options, compilerCalls) { + const QStringList arguments = tweakedArguments(file, options, extraParams); + unitsToAnalyze << AnalyzeUnit(file, arguments); + } } } diff --git a/src/plugins/cpptools/projectinfo.cpp b/src/plugins/cpptools/projectinfo.cpp index bc60ed970fc..1ac8ee35092 100644 --- a/src/plugins/cpptools/projectinfo.cpp +++ b/src/plugins/cpptools/projectinfo.cpp @@ -36,6 +36,13 @@ ProjectInfo::ProjectInfo(QPointer project) : m_project(project) {} +static bool operator==(const ProjectInfo::CompilerCallGroup &first, + const ProjectInfo::CompilerCallGroup &second) +{ + return first.groupId == second.groupId + && first.callsPerSourceFile == second.callsPerSourceFile; +} + bool ProjectInfo::operator ==(const ProjectInfo &other) const { return m_project == other.m_project diff --git a/src/plugins/cpptools/projectinfo.h b/src/plugins/cpptools/projectinfo.h index d5895997075..a22656d39ca 100644 --- a/src/plugins/cpptools/projectinfo.h +++ b/src/plugins/cpptools/projectinfo.h @@ -60,8 +60,13 @@ public: const QSet sourceFiles() const; const QByteArray defines() const; - // Source file --> List of compiler calls - typedef QHash> CompilerCallData; + struct CompilerCallGroup { + using CallsPerSourceFile = QHash>; + + QString groupId; + CallsPerSourceFile callsPerSourceFile; + }; + using CompilerCallData = QVector; void setCompilerCallData(const CompilerCallData &data); CompilerCallData compilerCallData() const; diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index bfe77d19644..d00f2acce76 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -754,6 +754,14 @@ static CppTools::ProjectFile::Kind cppFileType(const qbs::SourceArtifact &source return CppTools::ProjectFile::Unclassified; } +static QString groupLocationToProjectFile(const qbs::CodeLocation &location) +{ + return QString::fromLatin1("%1:%2:%3") + .arg(location.filePath()) + .arg(location.line()) + .arg(location.column()); +} + void QbsProject::updateCppCodeModel() { if (!m_projectData.isValid()) @@ -834,11 +842,7 @@ void QbsProject::updateCppCodeModel() ppBuilder.setPreCompiledHeaders(QStringList() << pch); ppBuilder.setDisplayName(grp.name()); - ppBuilder.setProjectFile(QString::fromLatin1("%1:%2:%3") - .arg(grp.location().filePath()) - .arg(grp.location().line()) - .arg(grp.location().column())); - + ppBuilder.setProjectFile(groupLocationToProjectFile(grp.location())); QHash filePathToSourceArtifact; foreach (const qbs::SourceArtifact &source, grp.allSourceArtifacts()) { @@ -902,6 +906,9 @@ void QbsProject::updateCppCompilerCallData() if (!group.isEnabled()) continue; + CppTools::ProjectInfo::CompilerCallGroup compilerCallGroup; + compilerCallGroup.groupId = groupLocationToProjectFile(group.location()); + foreach (const qbs::SourceArtifact &file, group.allSourceArtifacts()) { const QString &filePath = file.filePath(); if (!CppTools::ProjectFile::isSource(cppFileType(file))) @@ -920,8 +927,11 @@ void QbsProject::updateCppCompilerCallData() } if (!calls.isEmpty()) - data.insert(filePath, calls); + compilerCallGroup.callsPerSourceFile.insert(filePath, calls); } + + if (!compilerCallGroup.callsPerSourceFile.isEmpty()) + data.append(compilerCallGroup); } }