forked from qt-creator/qt-creator
Extract AnalyzeUnit out of ClangStaticAnalyzerRunControl
Reduces some noise in the implementation file. Change-Id: I24e81941c1888ba69f6b7f8dcab35956f60ca4e6 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
@@ -146,14 +146,13 @@ static QStringList argumentsFromProjectPart(const CppTools::ProjectPart::Ptr &pr
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromCompilerCallData(
|
static AnalyzeUnits unitsToAnalyzeFromCompilerCallData(
|
||||||
const ProjectInfo::CompilerCallData &compilerCallData,
|
const ProjectInfo::CompilerCallData &compilerCallData,
|
||||||
unsigned char wordWidth)
|
unsigned char wordWidth)
|
||||||
{
|
{
|
||||||
typedef ClangStaticAnalyzerRunControl::AnalyzeUnit AnalyzeUnit;
|
|
||||||
qCDebug(LOG) << "Taking arguments for analyzing from CompilerCallData.";
|
qCDebug(LOG) << "Taking arguments for analyzing from CompilerCallData.";
|
||||||
|
|
||||||
QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyze;
|
AnalyzeUnits unitsToAnalyze;
|
||||||
|
|
||||||
QHashIterator<QString, QList<QStringList> > it(compilerCallData);
|
QHashIterator<QString, QList<QStringList> > it(compilerCallData);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@@ -169,15 +168,13 @@ static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromCompi
|
|||||||
return unitsToAnalyze;
|
return unitsToAnalyze;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromProjectParts(
|
static AnalyzeUnits unitsToAnalyzeFromProjectParts(const QList<ProjectPart::Ptr> projectParts,
|
||||||
const QList<ProjectPart::Ptr> projectParts,
|
const QString &toolchainType,
|
||||||
const QString &toolchainType,
|
unsigned char wordWidth)
|
||||||
unsigned char wordWidth)
|
|
||||||
{
|
{
|
||||||
typedef ClangStaticAnalyzerRunControl::AnalyzeUnit AnalyzeUnit;
|
|
||||||
qCDebug(LOG) << "Taking arguments for analyzing from ProjectParts.";
|
qCDebug(LOG) << "Taking arguments for analyzing from ProjectParts.";
|
||||||
|
|
||||||
QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyze;
|
AnalyzeUnits unitsToAnalyze;
|
||||||
|
|
||||||
foreach (const ProjectPart::Ptr &projectPart, projectParts) {
|
foreach (const ProjectPart::Ptr &projectPart, projectParts) {
|
||||||
if (!projectPart->selectedForBuilding)
|
if (!projectPart->selectedForBuilding)
|
||||||
@@ -200,9 +197,9 @@ static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromProje
|
|||||||
return unitsToAnalyze;
|
return unitsToAnalyze;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> ClangStaticAnalyzerRunControl::unitsToAnalyze()
|
AnalyzeUnits ClangStaticAnalyzerRunControl::unitsToAnalyze()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_projectInfo.isValid(), return QList<ClangStaticAnalyzerRunControl::AnalyzeUnit>());
|
QTC_ASSERT(m_projectInfo.isValid(), return AnalyzeUnits());
|
||||||
|
|
||||||
const ProjectInfo::CompilerCallData compilerCallData = m_projectInfo.compilerCallData();
|
const ProjectInfo::CompilerCallData compilerCallData = m_projectInfo.compilerCallData();
|
||||||
if (!compilerCallData.isEmpty())
|
if (!compilerCallData.isEmpty())
|
||||||
@@ -249,7 +246,7 @@ bool ClangStaticAnalyzerRunControl::startEngine()
|
|||||||
m_clangLogFileDir = temporaryDir.path();
|
m_clangLogFileDir = temporaryDir.path();
|
||||||
|
|
||||||
// Collect files
|
// Collect files
|
||||||
QList<AnalyzeUnit> unitsToProcess = unitsToAnalyze();
|
AnalyzeUnits unitsToProcess = unitsToAnalyze();
|
||||||
Utils::sort(unitsToProcess, [](const AnalyzeUnit &a1, const AnalyzeUnit &a2) -> bool {
|
Utils::sort(unitsToProcess, [](const AnalyzeUnit &a1, const AnalyzeUnit &a2) -> bool {
|
||||||
return a1.file < a2.file;
|
return a1.file < a2.file;
|
||||||
});
|
});
|
||||||
|
@@ -31,19 +31,19 @@ namespace Internal {
|
|||||||
class ClangStaticAnalyzerRunner;
|
class ClangStaticAnalyzerRunner;
|
||||||
class Diagnostic;
|
class Diagnostic;
|
||||||
|
|
||||||
|
struct AnalyzeUnit {
|
||||||
|
AnalyzeUnit(const QString &file, const QStringList &options)
|
||||||
|
: file(file), arguments(options) {}
|
||||||
|
|
||||||
|
QString file;
|
||||||
|
QStringList arguments; // without file itself and "-o somePath"
|
||||||
|
};
|
||||||
|
typedef QList<AnalyzeUnit> AnalyzeUnits;
|
||||||
|
|
||||||
class ClangStaticAnalyzerRunControl : public Analyzer::AnalyzerRunControl
|
class ClangStaticAnalyzerRunControl : public Analyzer::AnalyzerRunControl
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
|
||||||
struct AnalyzeUnit {
|
|
||||||
AnalyzeUnit(const QString &file, const QStringList &options)
|
|
||||||
: file(file), arguments(options) {}
|
|
||||||
|
|
||||||
QString file;
|
|
||||||
QStringList arguments; // without file itself and "-o somePath"
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ClangStaticAnalyzerRunControl(const Analyzer::AnalyzerStartParameters &startParams,
|
explicit ClangStaticAnalyzerRunControl(const Analyzer::AnalyzerStartParameters &startParams,
|
||||||
ProjectExplorer::RunConfiguration *runConfiguration,
|
ProjectExplorer::RunConfiguration *runConfiguration,
|
||||||
@@ -56,7 +56,7 @@ signals:
|
|||||||
void newDiagnosticsAvailable(const QList<Diagnostic> &diagnostics);
|
void newDiagnosticsAvailable(const QList<Diagnostic> &diagnostics);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyze();
|
AnalyzeUnits unitsToAnalyze();
|
||||||
void analyzeNextFile();
|
void analyzeNextFile();
|
||||||
ClangStaticAnalyzerRunner *createRunner();
|
ClangStaticAnalyzerRunner *createRunner();
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ private:
|
|||||||
QString m_clangExecutable;
|
QString m_clangExecutable;
|
||||||
QString m_clangLogFileDir;
|
QString m_clangLogFileDir;
|
||||||
QFutureInterface<void> m_progress;
|
QFutureInterface<void> m_progress;
|
||||||
QList<AnalyzeUnit> m_unitsToProcess;
|
AnalyzeUnits m_unitsToProcess;
|
||||||
QSet<ClangStaticAnalyzerRunner *> m_runners;
|
QSet<ClangStaticAnalyzerRunner *> m_runners;
|
||||||
int m_initialFilesToProcessSize;
|
int m_initialFilesToProcessSize;
|
||||||
int m_filesAnalyzed;
|
int m_filesAnalyzed;
|
||||||
|
Reference in New Issue
Block a user