1/*===-- CXLoadedDiagnostic.h - Handling of persisent diags ------*- C++ -*-===*\
2|* *|
3|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4|* Exceptions. *|
5|* See https://llvm.org/LICENSE.txt for license information. *|
6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* Implements handling of persisent diagnostics. *|
11|* *|
12\*===----------------------------------------------------------------------===*/
13
14#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H
15#define LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H
16
17#include "CIndexDiagnostic.h"
18#include "llvm/ADT/StringRef.h"
19#include "clang/Basic/LLVM.h"
20#include <vector>
21
22namespace clang {
23class CXLoadedDiagnostic : public CXDiagnosticImpl {
24public:
25 CXLoadedDiagnostic() : CXDiagnosticImpl(LoadedDiagnosticKind),
26 severity(0), category(0) {}
27
28 ~CXLoadedDiagnostic() override;
29
30 /// Return the severity of the diagnostic.
31 CXDiagnosticSeverity getSeverity() const override;
32
33 /// Return the location of the diagnostic.
34 CXSourceLocation getLocation() const override;
35
36 /// Return the spelling of the diagnostic.
37 CXString getSpelling() const override;
38
39 /// Return the text for the diagnostic option.
40 CXString getDiagnosticOption(CXString *Disable) const override;
41
42 /// Return the category of the diagnostic.
43 unsigned getCategory() const override;
44
45 /// Return the category string of the diagnostic.
46 CXString getCategoryText() const override;
47
48 /// Return the number of source ranges for the diagnostic.
49 unsigned getNumRanges() const override;
50
51 /// Return the source ranges for the diagnostic.
52 CXSourceRange getRange(unsigned Range) const override;
53
54 /// Return the number of FixIts.
55 unsigned getNumFixIts() const override;
56
57 /// Return the FixIt information (source range and inserted text).
58 CXString getFixIt(unsigned FixIt,
59 CXSourceRange *ReplacementRange) const override;
60
61 static bool classof(const CXDiagnosticImpl *D) {
62 return D->getKind() == LoadedDiagnosticKind;
63 }
64
65 /// Decode the CXSourceLocation into file, line, column, and offset.
66 static void decodeLocation(CXSourceLocation location,
67 CXFile *file,
68 unsigned *line,
69 unsigned *column,
70 unsigned *offset);
71
72 struct Location {
73 CXFile file;
74 unsigned line = 0;
75 unsigned column = 0;
76 unsigned offset = 0;
77
78 Location() = default;
79 };
80
81 Location DiagLoc;
82
83 std::vector<CXSourceRange> Ranges;
84 std::vector<std::pair<CXSourceRange, const char *> > FixIts;
85 const char *Spelling;
86 llvm::StringRef DiagOption;
87 llvm::StringRef CategoryText;
88 unsigned severity;
89 unsigned category;
90};
91}
92
93#endif
94

source code of clang/tools/libclang/CXLoadedDiagnostic.h