ClangTools: Use Utils::FilePath in log reader

Change-Id: I3a16c2eb3ac26a0265ba24f2c6f2126c79c6c660
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-07-23 10:31:48 +02:00
parent 939df1c493
commit 917cf59a8c
3 changed files with 16 additions and 13 deletions

View File

@@ -468,7 +468,10 @@ Diagnostics ClangTidyClazyTool::read(const QString &filePath,
const QString &logFilePath,
QString *errorMessage) const
{
return readSerializedDiagnostics(filePath, projectFiles, logFilePath, errorMessage);
return readSerializedDiagnostics(Utils::FilePath::fromString(filePath),
projectFiles,
Utils::FilePath::fromString(logFilePath),
errorMessage);
}
void ClangTidyClazyTool::onNewDiagnosticsAvailable(const Diagnostics &diagnostics)

View File

@@ -182,15 +182,15 @@ static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic,
return diagnostic;
}
static Diagnostics readSerializedDiagnostics_helper(const QString &filePath,
static Diagnostics readSerializedDiagnostics_helper(const Utils::FilePath &filePath,
const QSet<Utils::FilePath> &projectFiles,
const QString &logFilePath)
const Utils::FilePath &logFilePath)
{
Diagnostics list;
CXLoadDiag_Error error;
CXString errorString;
CXDiagnosticSet diagnostics = clang_loadDiagnostics(logFilePath.toStdString().c_str(),
CXDiagnosticSet diagnostics = clang_loadDiagnostics(logFilePath.toString().toStdString().c_str(),
&error,
&errorString);
if (error != CXLoadDiag_None || !diagnostics)
@@ -200,7 +200,7 @@ static Diagnostics readSerializedDiagnostics_helper(const QString &filePath,
clang_disposeDiagnosticSet(diagnostics);
});
const QString nativeFilePath = QDir::toNativeSeparators(filePath);
const QString nativeFilePath = QDir::toNativeSeparators(filePath.toString());
for (unsigned i = 0; i < clang_getNumDiagnosticsInSet(diagnostics); ++i) {
CXDiagnostic cxDiagnostic = clang_getDiagnosticInSet(diagnostics, i);
Utils::ExecuteOnDestruction cleanUpDiagnostic([&]() {
@@ -216,24 +216,24 @@ static Diagnostics readSerializedDiagnostics_helper(const QString &filePath,
return list;
}
static bool checkFilePath(const QString &filePath, QString *errorMessage)
static bool checkFilePath(const Utils::FilePath &filePath, QString *errorMessage)
{
QFileInfo fi(filePath);
QFileInfo fi(filePath.toFileInfo());
if (!fi.exists() || !fi.isReadable()) {
if (errorMessage) {
*errorMessage
= QString(QT_TRANSLATE_NOOP("LogFileReader",
"File \"%1\" does not exist or is not readable."))
.arg(filePath);
.arg(filePath.toUserOutput());
}
return false;
}
return true;
}
Diagnostics readSerializedDiagnostics(const QString &filePath,
Diagnostics readSerializedDiagnostics(const Utils::FilePath &filePath,
const QSet<Utils::FilePath> &projectFiles,
const QString &logFilePath,
const Utils::FilePath &logFilePath,
QString *errorMessage)
{
if (!checkFilePath(logFilePath, errorMessage))

View File

@@ -27,16 +27,16 @@
#include "clangtoolsdiagnostic.h"
#include <QList>
#include <QSet>
namespace Utils { class FilePath; }
namespace ClangTools {
namespace Internal {
Diagnostics readSerializedDiagnostics(const QString &filePath,
Diagnostics readSerializedDiagnostics(const Utils::FilePath &filePath,
const QSet<Utils::FilePath> &projectFiles,
const QString &logFilePath,
const Utils::FilePath &logFilePath,
QString *errorMessage);
} // namespace Internal