[TargetVersion] Only enable on RISC-V and AArch64 (#115991)
[llvm-project.git] / clang / tools / libclang / CXLoadedDiagnostic.h
blob5ad9e1c32a92faa6c63cf190c2e5c3f256c279bd
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 \*===----------------------------------------------------------------------===*/
14 #ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H
15 #define LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H
17 #include "CIndexDiagnostic.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "clang/Basic/LLVM.h"
20 #include <vector>
22 namespace clang {
23 class CXLoadedDiagnostic : public CXDiagnosticImpl {
24 public:
25 CXLoadedDiagnostic() : CXDiagnosticImpl(LoadedDiagnosticKind),
26 severity(0), category(0) {}
28 ~CXLoadedDiagnostic() override;
30 /// Return the severity of the diagnostic.
31 CXDiagnosticSeverity getSeverity() const override;
33 /// Return the location of the diagnostic.
34 CXSourceLocation getLocation() const override;
36 /// Return the spelling of the diagnostic.
37 CXString getSpelling() const override;
39 /// Return the text for the diagnostic option.
40 CXString getDiagnosticOption(CXString *Disable) const override;
42 /// Return the category of the diagnostic.
43 unsigned getCategory() const override;
45 /// Return the category string of the diagnostic.
46 CXString getCategoryText() const override;
48 /// Return the number of source ranges for the diagnostic.
49 unsigned getNumRanges() const override;
51 /// Return the source ranges for the diagnostic.
52 CXSourceRange getRange(unsigned Range) const override;
54 /// Return the number of FixIts.
55 unsigned getNumFixIts() const override;
57 /// Return the FixIt information (source range and inserted text).
58 CXString getFixIt(unsigned FixIt,
59 CXSourceRange *ReplacementRange) const override;
61 static bool classof(const CXDiagnosticImpl *D) {
62 return D->getKind() == LoadedDiagnosticKind;
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);
72 struct Location {
73 CXFile file;
74 unsigned line = 0;
75 unsigned column = 0;
76 unsigned offset = 0;
78 Location() = default;
81 Location DiagLoc;
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;
93 #endif