aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/clangtools/clangtoolslogfilereader.h
blob: fb062f3b8e4720717e3d59defdea06eea9e51008 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once


#include "clangtoolsdiagnostic.h"

#include <optional>

namespace Utils { class FilePath; }

namespace ClangTools {
namespace Internal {

enum class OutputFileFormat { Yaml };

using AcceptDiagsFromFilePath = std::function<bool(const Utils::FilePath &)>;

// 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 = std::optional<LineColumnInfo>;
OptionalLineColumnInfo byteOffsetInUtf8TextToLineColumn(const char *text,
                                                        int offset,
                                                        int startLine = 1);

} // namespace Internal
} // namespace ClangTools