blob: 93995d7bb798c77ca3809357bd8aaec6fd2367a3 [file] [log] [blame]
Ted Kremenekd010ba42011-11-10 08:43:12 +00001/*===-- CXLoadedDiagnostic.h - Handling of persisent diags ------*- C++ -*-===*\
2|* *|
Chandler Carruth2946cd72019-01-19 08:50:56 +00003|* 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 *|
Ted Kremenekd010ba42011-11-10 08:43:12 +00007|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* Implements handling of persisent diagnostics. *|
11|* *|
12\*===----------------------------------------------------------------------===*/
13
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +000014#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H
15#define LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H
Ted Kremenekd010ba42011-11-10 08:43:12 +000016
17#include "CIndexDiagnostic.h"
18#include "llvm/ADT/StringRef.h"
19#include "clang/Basic/LLVM.h"
Ted Kremenekd010ba42011-11-10 08:43:12 +000020#include <vector>
21
22namespace clang {
23class CXLoadedDiagnostic : public CXDiagnosticImpl {
24public:
25 CXLoadedDiagnostic() : CXDiagnosticImpl(LoadedDiagnosticKind),
26 severity(0), category(0) {}
27
Alexander Kornienko34eb2072015-04-11 02:00:23 +000028 ~CXLoadedDiagnostic() override;
29
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000030 /// Return the severity of the diagnostic.
Craig Topper36835562014-03-15 07:47:46 +000031 CXDiagnosticSeverity getSeverity() const override;
32
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000033 /// Return the location of the diagnostic.
Craig Topper36835562014-03-15 07:47:46 +000034 CXSourceLocation getLocation() const override;
35
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000036 /// Return the spelling of the diagnostic.
Craig Topper36835562014-03-15 07:47:46 +000037 CXString getSpelling() const override;
38
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000039 /// Return the text for the diagnostic option.
Craig Topper36835562014-03-15 07:47:46 +000040 CXString getDiagnosticOption(CXString *Disable) const override;
41
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000042 /// Return the category of the diagnostic.
Craig Topper36835562014-03-15 07:47:46 +000043 unsigned getCategory() const override;
44
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000045 /// Return the category string of the diagnostic.
Craig Topper36835562014-03-15 07:47:46 +000046 CXString getCategoryText() const override;
47
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000048 /// Return the number of source ranges for the diagnostic.
Craig Topper36835562014-03-15 07:47:46 +000049 unsigned getNumRanges() const override;
50
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000051 /// Return the source ranges for the diagnostic.
Craig Topper36835562014-03-15 07:47:46 +000052 CXSourceRange getRange(unsigned Range) const override;
53
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000054 /// Return the number of FixIts.
Craig Topper36835562014-03-15 07:47:46 +000055 unsigned getNumFixIts() const override;
56
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000057 /// Return the FixIt information (source range and inserted text).
Craig Topper36835562014-03-15 07:47:46 +000058 CXString getFixIt(unsigned FixIt,
59 CXSourceRange *ReplacementRange) const override;
60
Ted Kremenekd010ba42011-11-10 08:43:12 +000061 static bool classof(const CXDiagnosticImpl *D) {
62 return D->getKind() == LoadedDiagnosticKind;
63 }
64
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000065 /// Decode the CXSourceLocation into file, line, column, and offset.
Ted Kremenekd010ba42011-11-10 08:43:12 +000066 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;
75 unsigned column;
76 unsigned offset;
77
78 Location() : line(0), column(0), offset(0) {}
79 };
80
81 Location DiagLoc;
82
83 std::vector<CXSourceRange> Ranges;
Dmitri Gribenko7d098082013-02-18 19:50:38 +000084 std::vector<std::pair<CXSourceRange, const char *> > FixIts;
85 const char *Spelling;
Ted Kremenekd010ba42011-11-10 08:43:12 +000086 llvm::StringRef DiagOption;
Ted Kremenek26a6d492012-04-12 00:03:31 +000087 llvm::StringRef CategoryText;
Ted Kremenekd010ba42011-11-10 08:43:12 +000088 unsigned severity;
89 unsigned category;
90};
Alexander Kornienkoab9db512015-06-22 23:07:51 +000091}
Ted Kremenekd010ba42011-11-10 08:43:12 +000092
93#endif