forked from qt-creator/qt-creator
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:
@@ -468,7 +468,10 @@ Diagnostics ClangTidyClazyTool::read(const QString &filePath,
|
|||||||
const QString &logFilePath,
|
const QString &logFilePath,
|
||||||
QString *errorMessage) const
|
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)
|
void ClangTidyClazyTool::onNewDiagnosticsAvailable(const Diagnostics &diagnostics)
|
||||||
|
@@ -182,15 +182,15 @@ static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic,
|
|||||||
return diagnostic;
|
return diagnostic;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Diagnostics readSerializedDiagnostics_helper(const QString &filePath,
|
static Diagnostics readSerializedDiagnostics_helper(const Utils::FilePath &filePath,
|
||||||
const QSet<Utils::FilePath> &projectFiles,
|
const QSet<Utils::FilePath> &projectFiles,
|
||||||
const QString &logFilePath)
|
const Utils::FilePath &logFilePath)
|
||||||
{
|
{
|
||||||
Diagnostics list;
|
Diagnostics list;
|
||||||
CXLoadDiag_Error error;
|
CXLoadDiag_Error error;
|
||||||
CXString errorString;
|
CXString errorString;
|
||||||
|
|
||||||
CXDiagnosticSet diagnostics = clang_loadDiagnostics(logFilePath.toStdString().c_str(),
|
CXDiagnosticSet diagnostics = clang_loadDiagnostics(logFilePath.toString().toStdString().c_str(),
|
||||||
&error,
|
&error,
|
||||||
&errorString);
|
&errorString);
|
||||||
if (error != CXLoadDiag_None || !diagnostics)
|
if (error != CXLoadDiag_None || !diagnostics)
|
||||||
@@ -200,7 +200,7 @@ static Diagnostics readSerializedDiagnostics_helper(const QString &filePath,
|
|||||||
clang_disposeDiagnosticSet(diagnostics);
|
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) {
|
for (unsigned i = 0; i < clang_getNumDiagnosticsInSet(diagnostics); ++i) {
|
||||||
CXDiagnostic cxDiagnostic = clang_getDiagnosticInSet(diagnostics, i);
|
CXDiagnostic cxDiagnostic = clang_getDiagnosticInSet(diagnostics, i);
|
||||||
Utils::ExecuteOnDestruction cleanUpDiagnostic([&]() {
|
Utils::ExecuteOnDestruction cleanUpDiagnostic([&]() {
|
||||||
@@ -216,24 +216,24 @@ static Diagnostics readSerializedDiagnostics_helper(const QString &filePath,
|
|||||||
return list;
|
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 (!fi.exists() || !fi.isReadable()) {
|
||||||
if (errorMessage) {
|
if (errorMessage) {
|
||||||
*errorMessage
|
*errorMessage
|
||||||
= QString(QT_TRANSLATE_NOOP("LogFileReader",
|
= QString(QT_TRANSLATE_NOOP("LogFileReader",
|
||||||
"File \"%1\" does not exist or is not readable."))
|
"File \"%1\" does not exist or is not readable."))
|
||||||
.arg(filePath);
|
.arg(filePath.toUserOutput());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Diagnostics readSerializedDiagnostics(const QString &filePath,
|
Diagnostics readSerializedDiagnostics(const Utils::FilePath &filePath,
|
||||||
const QSet<Utils::FilePath> &projectFiles,
|
const QSet<Utils::FilePath> &projectFiles,
|
||||||
const QString &logFilePath,
|
const Utils::FilePath &logFilePath,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (!checkFilePath(logFilePath, errorMessage))
|
if (!checkFilePath(logFilePath, errorMessage))
|
||||||
|
@@ -27,16 +27,16 @@
|
|||||||
|
|
||||||
#include "clangtoolsdiagnostic.h"
|
#include "clangtoolsdiagnostic.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QSet>
|
||||||
|
|
||||||
namespace Utils { class FilePath; }
|
namespace Utils { class FilePath; }
|
||||||
|
|
||||||
namespace ClangTools {
|
namespace ClangTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
Diagnostics readSerializedDiagnostics(const QString &filePath,
|
Diagnostics readSerializedDiagnostics(const Utils::FilePath &filePath,
|
||||||
const QSet<Utils::FilePath> &projectFiles,
|
const QSet<Utils::FilePath> &projectFiles,
|
||||||
const QString &logFilePath,
|
const Utils::FilePath &logFilePath,
|
||||||
QString *errorMessage);
|
QString *errorMessage);
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user