ClangTools: Use FilePath in AnalyzeUnit

Change-Id: Ic8e19053a60e7c4d801f32f9048b7c48d00b2a3d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2023-02-07 18:22:32 +01:00
parent 15841807d5
commit 9ad60cd891
4 changed files with 16 additions and 14 deletions

View File

@@ -189,7 +189,7 @@ void ClangToolRunWorker::start()
const AnalyzeInputData input{tool, m_diagnosticConfig, m_temporaryDir.path(),
m_environment, unit};
const auto setupHandler = [this, unit, tool] {
const QString filePath = FilePath::fromString(unit.file).toUserOutput();
const QString filePath = unit.file.toUserOutput();
appendMessage(Tr::tr("Analyzing \"%1\" [%2].").arg(filePath, clangToolName(tool)),
Utils::StdOutFormat);
return true;
@@ -231,7 +231,7 @@ void ClangToolRunWorker::onDone(const AnalyzeOutputData &output)
m_filesNotAnalyzed.insert(output.fileToAnalyze);
const QString message = Tr::tr("Failed to analyze \"%1\": %2")
.arg(output.fileToAnalyze, output.errorMessage);
.arg(output.fileToAnalyze.toUserOutput(), output.errorMessage);
appendMessage(message, Utils::StdErrFormat);
appendMessage(output.errorDetails, Utils::StdErrFormat);
return;
@@ -247,7 +247,8 @@ void ClangToolRunWorker::onDone(const AnalyzeOutputData &output)
m_filesAnalyzed.remove(output.fileToAnalyze);
m_filesNotAnalyzed.insert(output.fileToAnalyze);
qCDebug(LOG) << "onRunnerFinishedWithSuccess: Error reading log file:" << errorMessage;
appendMessage(Tr::tr("Failed to analyze \"%1\": %2").arg(output.fileToAnalyze, errorMessage),
appendMessage(Tr::tr("Failed to analyze \"%1\": %2")
.arg(output.fileToAnalyze.toUserOutput(), errorMessage),
Utils::StdErrFormat);
} else {
if (!m_filesNotAnalyzed.contains(output.fileToAnalyze))

View File

@@ -69,8 +69,8 @@ private:
std::unique_ptr<Utils::TaskTree> m_taskTree;
QSet<Utils::FilePath> m_projectFiles;
QSet<QString> m_filesAnalyzed;
QSet<QString> m_filesNotAnalyzed;
QSet<Utils::FilePath> m_filesAnalyzed;
QSet<Utils::FilePath> m_filesNotAnalyzed;
QElapsedTimer m_elapsed;
};

View File

@@ -41,7 +41,7 @@ AnalyzeUnit::AnalyzeUnit(const FileInfo &fileInfo,
UseLanguageDefines::No,
UseBuildSystemWarnings::No,
actualClangIncludeDir);
file = fileInfo.file.toString();
file = fileInfo.file;
arguments = extraClangToolsPrependOptions();
arguments.append(optionsBuilder.build(fileInfo.kind, CppEditor::getPchUsage()));
arguments.append(extraClangToolsAppendOptions());
@@ -85,9 +85,9 @@ static QStringList clangArguments(const ClangDiagnosticConfig &diagnosticConfig,
return arguments;
}
static QString createOutputFilePath(const FilePath &dirPath, const QString &fileToAnalyze)
static QString createOutputFilePath(const FilePath &dirPath, const FilePath &fileToAnalyze)
{
const QString fileName = QFileInfo(fileToAnalyze).fileName();
const QString fileName = fileToAnalyze.fileName();
const FilePath fileTemplate = dirPath.pathAppended("report-" + fileName + "-XXXXXX");
TemporaryFile temporaryFile("clangtools");
@@ -117,7 +117,7 @@ TaskItem clangToolTask(const AnalyzeInputData &input,
result << "-export-fixes=" + data->outputFilePath;
if (!input.overlayFilePath.isEmpty() && isVFSOverlaySupported(data->executable))
result << "--vfsoverlay=" + input.overlayFilePath;
result << QDir::toNativeSeparators(input.unit.file);
result << input.unit.file.nativePath();
return result;
};
@@ -134,8 +134,8 @@ TaskItem clangToolTask(const AnalyzeInputData &input,
}
QTC_CHECK(!input.unit.arguments.contains(QLatin1String("-o")));
QTC_CHECK(!input.unit.arguments.contains(input.unit.file));
QTC_ASSERT(FilePath::fromString(input.unit.file).exists(), return TaskAction::StopWithError);
QTC_CHECK(!input.unit.arguments.contains(input.unit.file.nativePath()));
QTC_ASSERT(input.unit.file.exists(), return TaskAction::StopWithError);
data->outputFilePath = createOutputFilePath(input.outputDirPath, input.unit.file);
QTC_ASSERT(!data->outputFilePath.isEmpty(), return TaskAction::StopWithError);

View File

@@ -14,12 +14,13 @@ namespace Utils::Tasking { class TaskItem; }
namespace ClangTools {
namespace Internal {
struct AnalyzeUnit {
struct AnalyzeUnit
{
AnalyzeUnit(const FileInfo &fileInfo,
const Utils::FilePath &clangResourceDir,
const QString &clangVersion);
QString file;
Utils::FilePath file;
QStringList arguments; // without file itself and "-o somePath"
};
using AnalyzeUnits = QList<AnalyzeUnit>;
@@ -37,7 +38,7 @@ struct AnalyzeInputData
struct AnalyzeOutputData
{
bool success = true;
QString fileToAnalyze;
Utils::FilePath fileToAnalyze;
QString outputFilePath;
CppEditor::ClangToolType toolType;
QString errorMessage = {};