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 01:07:33 +01:00
|
|
|
#include "clangtoolruncontrol.h"
|
|
|
|
|
|
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-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
|
|
|
};
|
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; }
|
2023-01-11 01:07:33 +01:00
|
|
|
QString fileToAnalyze() const { return m_input.unit.file; }
|
2019-08-29 14:25:49 +02:00
|
|
|
QString outputFilePath() const { return m_outputFilePath; }
|
2020-08-25 06:18:26 +02:00
|
|
|
bool supportsVFSOverlay() const;
|
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:
|
2019-08-29 14:25:49 +02:00
|
|
|
void finishedWithSuccess(const QString &fileToAnalyze);
|
2018-01-17 15:08:30 +01:00
|
|
|
void finishedWithFailure(const QString &errorMessage, const QString &errorDetails);
|
|
|
|
|
|
|
|
|
|
private:
|
2019-08-29 14:25:49 +02:00
|
|
|
void onProcessOutput();
|
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;
|
2019-08-29 14:25:49 +02:00
|
|
|
QString commandlineAndOutput() 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-01 14:54:15 +02:00
|
|
|
|
2019-08-29 14:25:49 +02:00
|
|
|
QString m_outputFilePath;
|
2018-01-17 15:08:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ClangTools
|