ClangTools: Support loading exported diagnostics

Add a new toolbar button to load diagnostics exported with

   $ clang-tidy -export-fixes=/path/to/file
   $ clazy-standalone -export-fixes=/path/to/file (master version)

Change-Id: I8316fe0706a18222e68220ef4fbfdc7ae8d09804
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-07-23 08:28:13 +02:00
parent 82bcf4e9f5
commit e6d16b6747
29 changed files with 877 additions and 3 deletions

View File

@@ -25,6 +25,8 @@
#pragma once
#include <utils/optional.h>
#include "clangtoolsdiagnostic.h"
namespace Utils { class FilePath; }
@@ -34,10 +36,27 @@ namespace Internal {
using AcceptDiagsFromFilePath = std::function<bool(const Utils::FilePath &)>;
// Reads diagnostics generated by "clang -serialize-diagnostics path/to/file"
Diagnostics readSerializedDiagnostics(const Utils::FilePath &logFilePath,
const Utils::FilePath &mainFilePath,
const AcceptDiagsFromFilePath &acceptFromFilePath,
QString *errorMessage);
// Reads diagnostics generated by "clang-tidy/clazy-standalone -export-fixes=path/to/file"
Diagnostics readExportedDiagnostics(const Utils::FilePath &logFilePath,
const AcceptDiagsFromFilePath &acceptFromFilePath,
QString *errorMessage);
// Exposed for tests
struct LineColumnInfo {
int line = 1; // 1-based
int column = 1; // 1-based
int lineStartOffset = 0; // for optimiation/caching purposes
};
using OptionalLineColumnInfo = Utils::optional<LineColumnInfo>;
OptionalLineColumnInfo byteOffsetInUtf8TextToLineColumn(const char *text,
int offset,
int startLine = 1);
} // namespace Internal
} // namespace ClangTools