1*7330f729Sjoerg /*===-- CXLoadedDiagnostic.h - Handling of persisent diags ------*- C++ -*-===*\ 2*7330f729Sjoerg |* *| 3*7330f729Sjoerg |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 4*7330f729Sjoerg |* Exceptions. *| 5*7330f729Sjoerg |* See https://llvm.org/LICENSE.txt for license information. *| 6*7330f729Sjoerg |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 7*7330f729Sjoerg |* *| 8*7330f729Sjoerg |*===----------------------------------------------------------------------===*| 9*7330f729Sjoerg |* *| 10*7330f729Sjoerg |* Implements handling of persisent diagnostics. *| 11*7330f729Sjoerg |* *| 12*7330f729Sjoerg \*===----------------------------------------------------------------------===*/ 13*7330f729Sjoerg 14*7330f729Sjoerg #ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H 15*7330f729Sjoerg #define LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H 16*7330f729Sjoerg 17*7330f729Sjoerg #include "CIndexDiagnostic.h" 18*7330f729Sjoerg #include "llvm/ADT/StringRef.h" 19*7330f729Sjoerg #include "clang/Basic/LLVM.h" 20*7330f729Sjoerg #include <vector> 21*7330f729Sjoerg 22*7330f729Sjoerg namespace clang { 23*7330f729Sjoerg class CXLoadedDiagnostic : public CXDiagnosticImpl { 24*7330f729Sjoerg public: CXLoadedDiagnostic()25*7330f729Sjoerg CXLoadedDiagnostic() : CXDiagnosticImpl(LoadedDiagnosticKind), 26*7330f729Sjoerg severity(0), category(0) {} 27*7330f729Sjoerg 28*7330f729Sjoerg ~CXLoadedDiagnostic() override; 29*7330f729Sjoerg 30*7330f729Sjoerg /// Return the severity of the diagnostic. 31*7330f729Sjoerg CXDiagnosticSeverity getSeverity() const override; 32*7330f729Sjoerg 33*7330f729Sjoerg /// Return the location of the diagnostic. 34*7330f729Sjoerg CXSourceLocation getLocation() const override; 35*7330f729Sjoerg 36*7330f729Sjoerg /// Return the spelling of the diagnostic. 37*7330f729Sjoerg CXString getSpelling() const override; 38*7330f729Sjoerg 39*7330f729Sjoerg /// Return the text for the diagnostic option. 40*7330f729Sjoerg CXString getDiagnosticOption(CXString *Disable) const override; 41*7330f729Sjoerg 42*7330f729Sjoerg /// Return the category of the diagnostic. 43*7330f729Sjoerg unsigned getCategory() const override; 44*7330f729Sjoerg 45*7330f729Sjoerg /// Return the category string of the diagnostic. 46*7330f729Sjoerg CXString getCategoryText() const override; 47*7330f729Sjoerg 48*7330f729Sjoerg /// Return the number of source ranges for the diagnostic. 49*7330f729Sjoerg unsigned getNumRanges() const override; 50*7330f729Sjoerg 51*7330f729Sjoerg /// Return the source ranges for the diagnostic. 52*7330f729Sjoerg CXSourceRange getRange(unsigned Range) const override; 53*7330f729Sjoerg 54*7330f729Sjoerg /// Return the number of FixIts. 55*7330f729Sjoerg unsigned getNumFixIts() const override; 56*7330f729Sjoerg 57*7330f729Sjoerg /// Return the FixIt information (source range and inserted text). 58*7330f729Sjoerg CXString getFixIt(unsigned FixIt, 59*7330f729Sjoerg CXSourceRange *ReplacementRange) const override; 60*7330f729Sjoerg classof(const CXDiagnosticImpl * D)61*7330f729Sjoerg static bool classof(const CXDiagnosticImpl *D) { 62*7330f729Sjoerg return D->getKind() == LoadedDiagnosticKind; 63*7330f729Sjoerg } 64*7330f729Sjoerg 65*7330f729Sjoerg /// Decode the CXSourceLocation into file, line, column, and offset. 66*7330f729Sjoerg static void decodeLocation(CXSourceLocation location, 67*7330f729Sjoerg CXFile *file, 68*7330f729Sjoerg unsigned *line, 69*7330f729Sjoerg unsigned *column, 70*7330f729Sjoerg unsigned *offset); 71*7330f729Sjoerg 72*7330f729Sjoerg struct Location { 73*7330f729Sjoerg CXFile file; 74*7330f729Sjoerg unsigned line; 75*7330f729Sjoerg unsigned column; 76*7330f729Sjoerg unsigned offset; 77*7330f729Sjoerg LocationLocation78*7330f729Sjoerg Location() : line(0), column(0), offset(0) {} 79*7330f729Sjoerg }; 80*7330f729Sjoerg 81*7330f729Sjoerg Location DiagLoc; 82*7330f729Sjoerg 83*7330f729Sjoerg std::vector<CXSourceRange> Ranges; 84*7330f729Sjoerg std::vector<std::pair<CXSourceRange, const char *> > FixIts; 85*7330f729Sjoerg const char *Spelling; 86*7330f729Sjoerg llvm::StringRef DiagOption; 87*7330f729Sjoerg llvm::StringRef CategoryText; 88*7330f729Sjoerg unsigned severity; 89*7330f729Sjoerg unsigned category; 90*7330f729Sjoerg }; 91*7330f729Sjoerg } 92*7330f729Sjoerg 93*7330f729Sjoerg #endif 94