Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 1 | /*===-- CXLoadedDiagnostic.h - Handling of persisent diags ------*- C++ -*-===*\ |
| 2 | |* *| |
| 3 | |* The LLVM Compiler Infrastructure *| |
| 4 | |* *| |
| 5 | |* This file is distributed under the University of Illinois Open Source *| |
| 6 | |* License. See LICENSE.TXT for details. *| |
| 7 | |* *| |
| 8 | |*===----------------------------------------------------------------------===*| |
| 9 | |* *| |
| 10 | |* Implements handling of persisent diagnostics. *| |
| 11 | |* *| |
| 12 | \*===----------------------------------------------------------------------===*/ |
| 13 | |
Benjamin Kramer | 2f5db8b | 2014-08-13 16:25:19 +0000 | [diff] [blame] | 14 | #ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H |
| 15 | #define LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 16 | |
| 17 | #include "CIndexDiagnostic.h" |
| 18 | #include "llvm/ADT/StringRef.h" |
| 19 | #include "clang/Basic/LLVM.h" |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 20 | #include <vector> |
| 21 | |
| 22 | namespace clang { |
| 23 | class CXLoadedDiagnostic : public CXDiagnosticImpl { |
| 24 | public: |
| 25 | CXLoadedDiagnostic() : CXDiagnosticImpl(LoadedDiagnosticKind), |
| 26 | severity(0), category(0) {} |
| 27 | |
Alexander Kornienko | 34eb207 | 2015-04-11 02:00:23 +0000 | [diff] [blame] | 28 | ~CXLoadedDiagnostic() override; |
| 29 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame^] | 30 | /// Return the severity of the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 31 | CXDiagnosticSeverity getSeverity() const override; |
| 32 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame^] | 33 | /// Return the location of the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 34 | CXSourceLocation getLocation() const override; |
| 35 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame^] | 36 | /// Return the spelling of the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 37 | CXString getSpelling() const override; |
| 38 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame^] | 39 | /// Return the text for the diagnostic option. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 40 | CXString getDiagnosticOption(CXString *Disable) const override; |
| 41 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame^] | 42 | /// Return the category of the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 43 | unsigned getCategory() const override; |
| 44 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame^] | 45 | /// Return the category string of the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 46 | CXString getCategoryText() const override; |
| 47 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame^] | 48 | /// Return the number of source ranges for the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 49 | unsigned getNumRanges() const override; |
| 50 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame^] | 51 | /// Return the source ranges for the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 52 | CXSourceRange getRange(unsigned Range) const override; |
| 53 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame^] | 54 | /// Return the number of FixIts. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 55 | unsigned getNumFixIts() const override; |
| 56 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame^] | 57 | /// Return the FixIt information (source range and inserted text). |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 58 | CXString getFixIt(unsigned FixIt, |
| 59 | CXSourceRange *ReplacementRange) const override; |
| 60 | |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 61 | static bool classof(const CXDiagnosticImpl *D) { |
| 62 | return D->getKind() == LoadedDiagnosticKind; |
| 63 | } |
| 64 | |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame^] | 65 | /// Decode the CXSourceLocation into file, line, column, and offset. |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 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; |
| 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 Gribenko | 7d09808 | 2013-02-18 19:50:38 +0000 | [diff] [blame] | 84 | std::vector<std::pair<CXSourceRange, const char *> > FixIts; |
| 85 | const char *Spelling; |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 86 | llvm::StringRef DiagOption; |
Ted Kremenek | 26a6d49 | 2012-04-12 00:03:31 +0000 | [diff] [blame] | 87 | llvm::StringRef CategoryText; |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 88 | unsigned severity; |
| 89 | unsigned category; |
| 90 | }; |
Alexander Kornienko | ab9db51 | 2015-06-22 23:07:51 +0000 | [diff] [blame] | 91 | } |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 92 | |
| 93 | #endif |