ClangTools: Use FilePath in ClangToolRunner::init()

One .path().path() less.

Change-Id: Ibf1b25acefafc1bb5359d839ebf272c3d1fb08d6
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-07-02 07:12:33 +02:00
parent 579e643f71
commit 9a82846de4
4 changed files with 9 additions and 10 deletions

View File

@@ -445,7 +445,7 @@ template<class T>
ClangToolRunner *ClangToolRunWorker::createRunner() ClangToolRunner *ClangToolRunWorker::createRunner()
{ {
auto runner = new T(m_diagnosticConfig, this); auto runner = new T(m_diagnosticConfig, this);
runner->init(m_temporaryDir.path().path(), m_environment); runner->init(m_temporaryDir.path(), m_environment);
connect(runner, &ClangToolRunner::finishedWithSuccess, connect(runner, &ClangToolRunner::finishedWithSuccess,
this, &ClangToolRunWorker::onRunnerFinishedWithSuccess); this, &ClangToolRunWorker::onRunnerFinishedWithSuccess);
connect(runner, &ClangToolRunner::finishedWithFailure, connect(runner, &ClangToolRunner::finishedWithFailure,

View File

@@ -78,7 +78,7 @@ ClangToolRunner::~ClangToolRunner()
m_process->deleteLater(); m_process->deleteLater();
} }
void ClangToolRunner::init(const QString &outputDirPath, const Environment &environment) void ClangToolRunner::init(const FilePath &outputDirPath, const Environment &environment)
{ {
m_outputDirPath = outputDirPath; m_outputDirPath = outputDirPath;
QTC_CHECK(!m_outputDirPath.isEmpty()); QTC_CHECK(!m_outputDirPath.isEmpty());
@@ -112,15 +112,14 @@ bool ClangToolRunner::supportsVFSOverlay() const
return it.value(); return it.value();
} }
static QString createOutputFilePath(const QString &dirPath, const QString &fileToAnalyze) static QString createOutputFilePath(const FilePath &dirPath, const QString &fileToAnalyze)
{ {
const QString fileName = QFileInfo(fileToAnalyze).fileName(); const QString fileName = QFileInfo(fileToAnalyze).fileName();
const QString fileTemplate = dirPath const FilePath fileTemplate = dirPath.pathAppended("report-" + fileName + "-XXXXXX");
+ QLatin1String("/report-") + fileName + QLatin1String("-XXXXXX");
Utils::TemporaryFile temporaryFile("clangtools"); TemporaryFile temporaryFile("clangtools");
temporaryFile.setAutoRemove(false); temporaryFile.setAutoRemove(false);
temporaryFile.setFileTemplate(fileTemplate); temporaryFile.setFileTemplate(fileTemplate.path());
if (temporaryFile.open()) { if (temporaryFile.open()) {
temporaryFile.close(); temporaryFile.close();
return temporaryFile.fileName(); return temporaryFile.fileName();

View File

@@ -44,7 +44,7 @@ public:
ClangToolRunner(QObject *parent = nullptr); ClangToolRunner(QObject *parent = nullptr);
~ClangToolRunner() override; ~ClangToolRunner() override;
void init(const QString &outputDirPath, const Utils::Environment &environment); void init(const Utils::FilePath &outputDirPath, const Utils::Environment &environment);
void setName(const QString &name) { m_name = name; } void setName(const QString &name) { m_name = name; }
void setExecutable(const QString &executable) { m_executable = executable; } void setExecutable(const QString &executable) { m_executable = executable; }
void setArgsCreator(const ArgsCreator &argsCreator) { m_argsCreator = argsCreator; } void setArgsCreator(const ArgsCreator &argsCreator) { m_argsCreator = argsCreator; }
@@ -79,7 +79,7 @@ private:
QString commandlineAndOutput() const; QString commandlineAndOutput() const;
private: private:
QString m_outputDirPath; Utils::FilePath m_outputDirPath;
Utils::QtcProcess *m_process = nullptr; Utils::QtcProcess *m_process = nullptr;
QString m_name; QString m_name;

View File

@@ -391,7 +391,7 @@ ClangToolRunner *DocumentClangToolRunner::createRunner(const CppTools::ClangDiag
const Utils::Environment &env) const Utils::Environment &env)
{ {
auto runner = new T(config, this); auto runner = new T(config, this);
runner->init(m_temporaryDir.path().path(), env); runner->init(m_temporaryDir.path(), env);
connect(runner, &ClangToolRunner::finishedWithSuccess, connect(runner, &ClangToolRunner::finishedWithSuccess,
this, &DocumentClangToolRunner::onSuccess); this, &DocumentClangToolRunner::onSuccess);
connect(runner, &ClangToolRunner::finishedWithFailure, connect(runner, &ClangToolRunner::finishedWithFailure,