diff options
author | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-04-16 13:33:57 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-05-05 16:26:37 +0300 |
commit | dca023a8551c8a20b33d846dae57dc522c68ebf9 (patch) | |
tree | 63407afda6713a76ef0f6338e1ecff4f92207c2f /plugins | |
parent | 19f4072142d94861ab488b3e2255af0597fa59a6 (diff) | |
download | qt-creator-dca023a8551c8a20b33d846dae57dc522c68ebf9.tar.gz |
Mini refactorings in ClangStaticAnalyzerRunControl
...making ClangStaticAnalyzerRunControl::startEngine() a bit shorter.
Change-Id: Ie1547d81ba8443d663983bc0c2aa8f342932c338
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp | 37 | ||||
-rw-r--r-- | plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h | 2 |
2 files changed, 24 insertions, 15 deletions
diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp index 80338bdd77..1ec5e6d264 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp @@ -197,16 +197,24 @@ static AnalyzeUnits unitsToAnalyzeFromProjectParts(const QList<ProjectPart::Ptr> return unitsToAnalyze; } -AnalyzeUnits ClangStaticAnalyzerRunControl::unitsToAnalyze() +AnalyzeUnits ClangStaticAnalyzerRunControl::sortedUnitsToAnalyze() { QTC_ASSERT(m_projectInfo.isValid(), return AnalyzeUnits()); + AnalyzeUnits units; const ProjectInfo::CompilerCallData compilerCallData = m_projectInfo.compilerCallData(); - if (!compilerCallData.isEmpty()) - return unitsToAnalyzeFromCompilerCallData(compilerCallData, m_wordWidth); - return unitsToAnalyzeFromProjectParts(m_projectInfo.projectParts(), - m_toolchainType, - m_wordWidth); + if (compilerCallData.isEmpty()) { + units = unitsToAnalyzeFromProjectParts(m_projectInfo.projectParts(), + m_toolchainType, + m_wordWidth); + } else { + units = unitsToAnalyzeFromCompilerCallData(compilerCallData, m_wordWidth); + } + + Utils::sort(units, [](const AnalyzeUnit &a1, const AnalyzeUnit &a2) -> bool { + return a1.file < a2.file; + }); + return units; } static QDebug operator<<(QDebug debug, const Utils::Environment &environment) @@ -216,6 +224,13 @@ static QDebug operator<<(QDebug debug, const Utils::Environment &environment) return debug; } +static QDebug operator<<(QDebug debug, const AnalyzeUnits &analyzeUnits) +{ + foreach (const AnalyzeUnit &unit, analyzeUnits) + debug << "\n " << unit.file; + return debug; +} + bool ClangStaticAnalyzerRunControl::startEngine() { emit starting(this); @@ -253,14 +268,8 @@ bool ClangStaticAnalyzerRunControl::startEngine() m_clangLogFileDir = temporaryDir.path(); // Collect files - AnalyzeUnits unitsToProcess = unitsToAnalyze(); - Utils::sort(unitsToProcess, [](const AnalyzeUnit &a1, const AnalyzeUnit &a2) -> bool { - return a1.file < a2.file; - }); - - qCDebug(LOG) << "Files to process:"; - foreach (const AnalyzeUnit &fileConfig, unitsToProcess) - qCDebug(LOG) << fileConfig.file; + const AnalyzeUnits unitsToProcess = sortedUnitsToAnalyze(); + qCDebug(LOG) << "Files to process:" << unitsToProcess; m_unitsToProcess = unitsToProcess; m_initialFilesToProcessSize = m_unitsToProcess.count(); m_filesAnalyzed = 0; diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h index 167539b2a9..783713535d 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h @@ -56,7 +56,7 @@ signals: void newDiagnosticsAvailable(const QList<Diagnostic> &diagnostics); private: - AnalyzeUnits unitsToAnalyze(); + AnalyzeUnits sortedUnitsToAnalyze(); void analyzeNextFile(); ClangStaticAnalyzerRunner *createRunner(); |