Mini refactorings in ClangStaticAnalyzerRunControl

...making ClangStaticAnalyzerRunControl::startEngine() a bit shorter.

Change-Id: Ie1547d81ba8443d663983bc0c2aa8f342932c338
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-04-16 13:33:57 +02:00
parent 19f4072142
commit dca023a855
2 changed files with 24 additions and 15 deletions

View File

@@ -197,16 +197,24 @@ static AnalyzeUnits unitsToAnalyzeFromProjectParts(const QList<ProjectPart::Ptr>
return unitsToAnalyze; return unitsToAnalyze;
} }
AnalyzeUnits ClangStaticAnalyzerRunControl::unitsToAnalyze() AnalyzeUnits ClangStaticAnalyzerRunControl::sortedUnitsToAnalyze()
{ {
QTC_ASSERT(m_projectInfo.isValid(), return AnalyzeUnits()); QTC_ASSERT(m_projectInfo.isValid(), return AnalyzeUnits());
AnalyzeUnits units;
const ProjectInfo::CompilerCallData compilerCallData = m_projectInfo.compilerCallData(); const ProjectInfo::CompilerCallData compilerCallData = m_projectInfo.compilerCallData();
if (!compilerCallData.isEmpty()) if (compilerCallData.isEmpty()) {
return unitsToAnalyzeFromCompilerCallData(compilerCallData, m_wordWidth); units = unitsToAnalyzeFromProjectParts(m_projectInfo.projectParts(),
return unitsToAnalyzeFromProjectParts(m_projectInfo.projectParts(),
m_toolchainType, m_toolchainType,
m_wordWidth); 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) static QDebug operator<<(QDebug debug, const Utils::Environment &environment)
@@ -216,6 +224,13 @@ static QDebug operator<<(QDebug debug, const Utils::Environment &environment)
return debug; return debug;
} }
static QDebug operator<<(QDebug debug, const AnalyzeUnits &analyzeUnits)
{
foreach (const AnalyzeUnit &unit, analyzeUnits)
debug << "\n " << unit.file;
return debug;
}
bool ClangStaticAnalyzerRunControl::startEngine() bool ClangStaticAnalyzerRunControl::startEngine()
{ {
emit starting(this); emit starting(this);
@@ -253,14 +268,8 @@ bool ClangStaticAnalyzerRunControl::startEngine()
m_clangLogFileDir = temporaryDir.path(); m_clangLogFileDir = temporaryDir.path();
// Collect files // Collect files
AnalyzeUnits unitsToProcess = unitsToAnalyze(); const AnalyzeUnits unitsToProcess = sortedUnitsToAnalyze();
Utils::sort(unitsToProcess, [](const AnalyzeUnit &a1, const AnalyzeUnit &a2) -> bool { qCDebug(LOG) << "Files to process:" << unitsToProcess;
return a1.file < a2.file;
});
qCDebug(LOG) << "Files to process:";
foreach (const AnalyzeUnit &fileConfig, unitsToProcess)
qCDebug(LOG) << fileConfig.file;
m_unitsToProcess = unitsToProcess; m_unitsToProcess = unitsToProcess;
m_initialFilesToProcessSize = m_unitsToProcess.count(); m_initialFilesToProcessSize = m_unitsToProcess.count();
m_filesAnalyzed = 0; m_filesAnalyzed = 0;

View File

@@ -56,7 +56,7 @@ signals:
void newDiagnosticsAvailable(const QList<Diagnostic> &diagnostics); void newDiagnosticsAvailable(const QList<Diagnostic> &diagnostics);
private: private:
AnalyzeUnits unitsToAnalyze(); AnalyzeUnits sortedUnitsToAnalyze();
void analyzeNextFile(); void analyzeNextFile();
ClangStaticAnalyzerRunner *createRunner(); ClangStaticAnalyzerRunner *createRunner();