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