diff options
| author | Ted Kremenek <kremenek@apple.com> | 2011-10-31 21:40:19 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2011-10-31 21:40:19 +0000 |
| commit | bb2c7101b5f75498662443442ffe82575829255b (patch) | |
| tree | f79eb5f12d91aad2ed396a02b638a84b07a04280 /clang/tools/libclang/CIndexDiagnostic.h | |
| parent | 3689337c8e26fee4dcbdda478ebb6a88ce904069 (diff) | |
| download | bcm5719-llvm-bb2c7101b5f75498662443442ffe82575829255b.tar.gz bcm5719-llvm-bb2c7101b5f75498662443442ffe82575829255b.zip | |
[libclang] Add CXDiagnosticImpl to represent a super class for the implementation backing a CXDiagnostic. This allows CXStoredDiagnostic
to be just one possible implementation of a CXDiagnostic.
llvm-svn: 143368
Diffstat (limited to 'clang/tools/libclang/CIndexDiagnostic.h')
| -rw-r--r-- | clang/tools/libclang/CIndexDiagnostic.h | 84 |
1 files changed, 82 insertions, 2 deletions
diff --git a/clang/tools/libclang/CIndexDiagnostic.h b/clang/tools/libclang/CIndexDiagnostic.h index 0d935fae660..07b6b159687 100644 --- a/clang/tools/libclang/CIndexDiagnostic.h +++ b/clang/tools/libclang/CIndexDiagnostic.h @@ -13,19 +13,99 @@ #ifndef LLVM_CLANG_CINDEX_DIAGNOSTIC_H #define LLVM_CLANG_CINDEX_DIAGNOSTIC_H +#include "clang-c/Index.h" + namespace clang { class LangOptions; class StoredDiagnostic; +class CXDiagnosticImpl { +public: + enum Kind { StoredDiagnosticKind, SerializedDiagnosticKind }; + + virtual ~CXDiagnosticImpl(); + + /// \brief Return the severity of the diagnostic. + virtual CXDiagnosticSeverity getSeverity() const = 0; + + /// \brief Return the location of the diagnostic. + virtual CXSourceLocation getLocation() const = 0; + + /// \brief Return the spelling of the diagnostic. + virtual CXString getSpelling() const = 0; + + /// \brief Return the text for the diagnostic option. + virtual CXString getDiagnosticOption(CXString *Disable) const = 0; + + /// \brief Return the category of the diagnostic. + virtual unsigned getCategory() const = 0; + + /// \brief Return the number of source ranges for the diagnostic. + virtual unsigned getNumRanges() const = 0; + + /// \brief Return the source ranges for the diagnostic. + virtual CXSourceRange getRange(unsigned Range) const = 0; + + /// \brief Return the number of FixIts. + virtual unsigned getNumFixIts() const = 0; + + /// \brief Return the FixIt information (source range and inserted text). + virtual CXString getFixIt(unsigned FixIt, + CXSourceRange *ReplacementRange) const = 0; + + Kind getKind() const { return K; } + +protected: + CXDiagnosticImpl(Kind k) : K(k) {} + +private: + Kind K; +}; + /// \brief The storage behind a CXDiagnostic -struct CXStoredDiagnostic { +struct CXStoredDiagnostic : public CXDiagnosticImpl { const StoredDiagnostic &Diag; const LangOptions &LangOpts; CXStoredDiagnostic(const StoredDiagnostic &Diag, const LangOptions &LangOpts) - : Diag(Diag), LangOpts(LangOpts) { } + : CXDiagnosticImpl(StoredDiagnosticKind), + Diag(Diag), LangOpts(LangOpts) { } + + virtual ~CXStoredDiagnostic() {} + + /// \brief Return the severity of the diagnostic. + virtual CXDiagnosticSeverity getSeverity() const; + + /// \brief Return the location of the diagnostic. + virtual CXSourceLocation getLocation() const; + + /// \brief Return the spelling of the diagnostic. + virtual CXString getSpelling() const; + + /// \brief Return the text for the diagnostic option. + virtual CXString getDiagnosticOption(CXString *Disable) const; + + /// \brief Return the category of the diagnostic. + virtual unsigned getCategory() const; + + /// \brief Return the number of source ranges for the diagnostic. + virtual unsigned getNumRanges() const; + + /// \brief Return the source ranges for the diagnostic. + virtual CXSourceRange getRange(unsigned Range) const; + + /// \brief Return the number of FixIts. + virtual unsigned getNumFixIts() const; + + /// \brief Return the FixIt information (source range and inserted text). + virtual CXString getFixIt(unsigned FixIt, + CXSourceRange *ReplacementRange) const; + + static bool classof(const CXDiagnosticImpl *D) { + return D->getKind() == StoredDiagnosticKind; + } }; } // end namespace clang |

