Douglas Gregor | d93256e | 2010-01-28 06:00:51 +0000 | [diff] [blame] | 1 | /*===-- CIndexDiagnostic.h - Diagnostics C Interface ------------*- C++ -*-===*\ |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 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 the diagnostic functions of the Clang C interface. *| |
| 11 | |* *| |
| 12 | \*===----------------------------------------------------------------------===*/ |
| 13 | #ifndef LLVM_CLANG_CINDEX_DIAGNOSTIC_H |
| 14 | #define LLVM_CLANG_CINDEX_DIAGNOSTIC_H |
| 15 | |
Ted Kremenek | 1edabbc | 2011-10-31 21:40:19 +0000 | [diff] [blame^] | 16 | #include "clang-c/Index.h" |
| 17 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 18 | namespace clang { |
| 19 | |
Daniel Dunbar | 35b8440 | 2010-01-30 23:31:40 +0000 | [diff] [blame] | 20 | class LangOptions; |
Benjamin Kramer | b846deb | 2010-04-12 19:45:50 +0000 | [diff] [blame] | 21 | class StoredDiagnostic; |
Daniel Dunbar | 4914612 | 2010-01-30 23:31:49 +0000 | [diff] [blame] | 22 | |
Ted Kremenek | 1edabbc | 2011-10-31 21:40:19 +0000 | [diff] [blame^] | 23 | class CXDiagnosticImpl { |
| 24 | public: |
| 25 | enum Kind { StoredDiagnosticKind, SerializedDiagnosticKind }; |
| 26 | |
| 27 | virtual ~CXDiagnosticImpl(); |
| 28 | |
| 29 | /// \brief Return the severity of the diagnostic. |
| 30 | virtual CXDiagnosticSeverity getSeverity() const = 0; |
| 31 | |
| 32 | /// \brief Return the location of the diagnostic. |
| 33 | virtual CXSourceLocation getLocation() const = 0; |
| 34 | |
| 35 | /// \brief Return the spelling of the diagnostic. |
| 36 | virtual CXString getSpelling() const = 0; |
| 37 | |
| 38 | /// \brief Return the text for the diagnostic option. |
| 39 | virtual CXString getDiagnosticOption(CXString *Disable) const = 0; |
| 40 | |
| 41 | /// \brief Return the category of the diagnostic. |
| 42 | virtual unsigned getCategory() const = 0; |
| 43 | |
| 44 | /// \brief Return the number of source ranges for the diagnostic. |
| 45 | virtual unsigned getNumRanges() const = 0; |
| 46 | |
| 47 | /// \brief Return the source ranges for the diagnostic. |
| 48 | virtual CXSourceRange getRange(unsigned Range) const = 0; |
| 49 | |
| 50 | /// \brief Return the number of FixIts. |
| 51 | virtual unsigned getNumFixIts() const = 0; |
| 52 | |
| 53 | /// \brief Return the FixIt information (source range and inserted text). |
| 54 | virtual CXString getFixIt(unsigned FixIt, |
| 55 | CXSourceRange *ReplacementRange) const = 0; |
| 56 | |
| 57 | Kind getKind() const { return K; } |
| 58 | |
| 59 | protected: |
| 60 | CXDiagnosticImpl(Kind k) : K(k) {} |
| 61 | |
| 62 | private: |
| 63 | Kind K; |
| 64 | }; |
| 65 | |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 66 | /// \brief The storage behind a CXDiagnostic |
Ted Kremenek | 1edabbc | 2011-10-31 21:40:19 +0000 | [diff] [blame^] | 67 | struct CXStoredDiagnostic : public CXDiagnosticImpl { |
Douglas Gregor | a88084b | 2010-02-18 18:08:43 +0000 | [diff] [blame] | 68 | const StoredDiagnostic &Diag; |
| 69 | const LangOptions &LangOpts; |
| 70 | |
| 71 | CXStoredDiagnostic(const StoredDiagnostic &Diag, |
| 72 | const LangOptions &LangOpts) |
Ted Kremenek | 1edabbc | 2011-10-31 21:40:19 +0000 | [diff] [blame^] | 73 | : CXDiagnosticImpl(StoredDiagnosticKind), |
| 74 | Diag(Diag), LangOpts(LangOpts) { } |
| 75 | |
| 76 | virtual ~CXStoredDiagnostic() {} |
| 77 | |
| 78 | /// \brief Return the severity of the diagnostic. |
| 79 | virtual CXDiagnosticSeverity getSeverity() const; |
| 80 | |
| 81 | /// \brief Return the location of the diagnostic. |
| 82 | virtual CXSourceLocation getLocation() const; |
| 83 | |
| 84 | /// \brief Return the spelling of the diagnostic. |
| 85 | virtual CXString getSpelling() const; |
| 86 | |
| 87 | /// \brief Return the text for the diagnostic option. |
| 88 | virtual CXString getDiagnosticOption(CXString *Disable) const; |
| 89 | |
| 90 | /// \brief Return the category of the diagnostic. |
| 91 | virtual unsigned getCategory() const; |
| 92 | |
| 93 | /// \brief Return the number of source ranges for the diagnostic. |
| 94 | virtual unsigned getNumRanges() const; |
| 95 | |
| 96 | /// \brief Return the source ranges for the diagnostic. |
| 97 | virtual CXSourceRange getRange(unsigned Range) const; |
| 98 | |
| 99 | /// \brief Return the number of FixIts. |
| 100 | virtual unsigned getNumFixIts() const; |
| 101 | |
| 102 | /// \brief Return the FixIt information (source range and inserted text). |
| 103 | virtual CXString getFixIt(unsigned FixIt, |
| 104 | CXSourceRange *ReplacementRange) const; |
| 105 | |
| 106 | static bool classof(const CXDiagnosticImpl *D) { |
| 107 | return D->getKind() == StoredDiagnosticKind; |
| 108 | } |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 109 | }; |
Douglas Gregor | d93256e | 2010-01-28 06:00:51 +0000 | [diff] [blame] | 110 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 111 | } // end namespace clang |
| 112 | |
| 113 | #endif // LLVM_CLANG_CINDEX_DIAGNOSTIC_H |