2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2018-01-17 15:08:30 +01:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-01-11 15:32:46 +01:00
|
|
|
#include "clangfileinfo.h"
|
2023-01-11 01:07:33 +01:00
|
|
|
|
2023-01-10 17:51:34 +01:00
|
|
|
#include <cppeditor/clangdiagnosticconfig.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/environment.h>
|
2022-06-16 10:34:01 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2019-08-29 14:25:49 +02:00
|
|
|
#include <memory>
|
|
|
|
|
|
2018-01-17 15:08:30 +01:00
|
|
|
namespace ClangTools {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2023-01-11 15:32:46 +01:00
|
|
|
struct AnalyzeUnit {
|
|
|
|
|
AnalyzeUnit(const FileInfo &fileInfo,
|
|
|
|
|
const Utils::FilePath &clangResourceDir,
|
|
|
|
|
const QString &clangVersion);
|
|
|
|
|
|
|
|
|
|
QString file;
|
|
|
|
|
QStringList arguments; // without file itself and "-o somePath"
|
|
|
|
|
};
|
|
|
|
|
using AnalyzeUnits = QList<AnalyzeUnit>;
|
|
|
|
|
|
2023-01-10 17:51:34 +01:00
|
|
|
struct AnalyzeInputData
|
|
|
|
|
{
|
|
|
|
|
CppEditor::ClangToolType tool = CppEditor::ClangToolType::Tidy;
|
|
|
|
|
CppEditor::ClangDiagnosticConfig config;
|
|
|
|
|
Utils::FilePath outputDirPath;
|
|
|
|
|
Utils::Environment environment;
|
2023-01-11 01:07:33 +01:00
|
|
|
AnalyzeUnit unit;
|
2023-01-10 18:23:24 +01:00
|
|
|
QString overlayFilePath = {};
|
2023-01-10 17:51:34 +01:00
|
|
|
};
|
2023-01-11 15:32:46 +01:00
|
|
|
|
|
|
|
|
struct AnalyzeOutputData
|
|
|
|
|
{
|
|
|
|
|
bool success = true;
|
|
|
|
|
QString fileToAnalyze;
|
|
|
|
|
QString outputFilePath;
|
|
|
|
|
QString toolName;
|
|
|
|
|
QString errorMessage = {};
|
|
|
|
|
QString errorDetails = {};
|
|
|
|
|
};
|
|
|
|
|
|
2018-01-17 15:08:30 +01:00
|
|
|
class ClangToolRunner : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2023-01-10 17:51:34 +01:00
|
|
|
ClangToolRunner(const AnalyzeInputData &input, QObject *parent = nullptr);
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2019-08-01 15:18:32 +02:00
|
|
|
QString name() const { return m_name; }
|
2019-08-29 14:25:49 +02:00
|
|
|
|
|
|
|
|
// compilerOptions is expected to contain everything except:
|
|
|
|
|
// (1) file to analyze
|
|
|
|
|
// (2) -o output-file
|
2023-01-11 01:07:33 +01:00
|
|
|
bool run();
|
2018-01-17 15:08:30 +01:00
|
|
|
|
|
|
|
|
signals:
|
2023-01-11 15:32:46 +01:00
|
|
|
void done(const AnalyzeOutputData &output);
|
2018-01-17 15:08:30 +01:00
|
|
|
|
|
|
|
|
private:
|
2022-04-14 09:14:31 +02:00
|
|
|
void onProcessDone();
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2023-01-10 17:51:34 +01:00
|
|
|
QStringList mainToolArguments() const;
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2023-01-11 01:07:33 +01:00
|
|
|
const AnalyzeInputData m_input;
|
2022-06-16 10:34:01 +02:00
|
|
|
Utils::QtcProcess m_process;
|
2018-01-17 15:08:30 +01:00
|
|
|
|
2019-08-01 14:54:15 +02:00
|
|
|
QString m_name;
|
2021-08-12 09:19:55 +02:00
|
|
|
Utils::FilePath m_executable;
|
2019-08-29 14:25:49 +02:00
|
|
|
QString m_outputFilePath;
|
2018-01-17 15:08:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ClangTools
|