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" |
| 20 | #include <string> |
| 21 | #include <vector> |
| 22 | |
| 23 | namespace clang { |
| 24 | class CXLoadedDiagnostic : public CXDiagnosticImpl { |
| 25 | public: |
| 26 | CXLoadedDiagnostic() : CXDiagnosticImpl(LoadedDiagnosticKind), |
| 27 | severity(0), category(0) {} |
| 28 | |
| 29 | virtual ~CXLoadedDiagnostic(); |
| 30 | |
| 31 | /// \brief Return the severity of the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 32 | CXDiagnosticSeverity getSeverity() const override; |
| 33 | |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 34 | /// \brief Return the location of the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 35 | CXSourceLocation getLocation() const override; |
| 36 | |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 37 | /// \brief Return the spelling of the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 38 | CXString getSpelling() const override; |
| 39 | |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 40 | /// \brief Return the text for the diagnostic option. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 41 | CXString getDiagnosticOption(CXString *Disable) const override; |
| 42 | |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 43 | /// \brief Return the category of the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 44 | unsigned getCategory() const override; |
| 45 | |
Ted Kremenek | 26a6d49 | 2012-04-12 00:03:31 +0000 | [diff] [blame] | 46 | /// \brief Return the category string of the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 47 | CXString getCategoryText() const override; |
| 48 | |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 49 | /// \brief Return the number of source ranges for the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 50 | unsigned getNumRanges() const override; |
| 51 | |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 52 | /// \brief Return the source ranges for the diagnostic. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 53 | CXSourceRange getRange(unsigned Range) const override; |
| 54 | |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 55 | /// \brief Return the number of FixIts. |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 56 | unsigned getNumFixIts() const override; |
| 57 | |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 58 | /// \brief Return the FixIt information (source range and inserted text). |
Craig Topper | 3683556 | 2014-03-15 07:47:46 +0000 | [diff] [blame] | 59 | CXString getFixIt(unsigned FixIt, |
| 60 | CXSourceRange *ReplacementRange) const override; |
| 61 | |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 62 | static bool classof(const CXDiagnosticImpl *D) { |
| 63 | return D->getKind() == LoadedDiagnosticKind; |
| 64 | } |
| 65 | |
| 66 | /// \brief Decode the CXSourceLocation into file, line, column, and offset. |
| 67 | static void decodeLocation(CXSourceLocation location, |
| 68 | CXFile *file, |
| 69 | unsigned *line, |
| 70 | unsigned *column, |
| 71 | unsigned *offset); |
| 72 | |
| 73 | struct Location { |
| 74 | CXFile file; |
| 75 | unsigned line; |
| 76 | unsigned column; |
| 77 | unsigned offset; |
| 78 | |
| 79 | Location() : line(0), column(0), offset(0) {} |
| 80 | }; |
| 81 | |
| 82 | Location DiagLoc; |
| 83 | |
| 84 | std::vector<CXSourceRange> Ranges; |
Dmitri Gribenko | 7d09808 | 2013-02-18 19:50:38 +0000 | [diff] [blame] | 85 | std::vector<std::pair<CXSourceRange, const char *> > FixIts; |
| 86 | const char *Spelling; |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 87 | llvm::StringRef DiagOption; |
Ted Kremenek | 26a6d49 | 2012-04-12 00:03:31 +0000 | [diff] [blame] | 88 | llvm::StringRef CategoryText; |
Ted Kremenek | d010ba4 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 89 | unsigned severity; |
| 90 | unsigned category; |
| 91 | }; |
| 92 | } |
| 93 | |
| 94 | #endif |