1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | #include "DiagnosticNames.h" |
10 | #include "clang/Basic/AllDiagnostics.h" |
11 | #include "llvm/ADT/STLExtras.h" |
12 | |
13 | using namespace clang; |
14 | using namespace diagtool; |
15 | |
16 | static const DiagnosticRecord BuiltinDiagnosticsByName[] = { |
17 | #define DIAG_NAME_INDEX(ENUM) { #ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t) }, |
18 | #include "clang/Basic/DiagnosticIndexName.inc" |
19 | #undef DIAG_NAME_INDEX |
20 | }; |
21 | |
22 | llvm::ArrayRef<DiagnosticRecord> diagtool::getBuiltinDiagnosticsByName() { |
23 | return llvm::makeArrayRef(BuiltinDiagnosticsByName); |
24 | } |
25 | |
26 | |
27 | |
28 | |
29 | static const DiagnosticRecord BuiltinDiagnosticsByID[] = { |
30 | #define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC,GROUP, \ |
31 | SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) \ |
32 | { #ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t) }, |
33 | #include "clang/Basic/DiagnosticCommonKinds.inc" |
34 | #include "clang/Basic/DiagnosticCrossTUKinds.inc" |
35 | #include "clang/Basic/DiagnosticDriverKinds.inc" |
36 | #include "clang/Basic/DiagnosticFrontendKinds.inc" |
37 | #include "clang/Basic/DiagnosticSerializationKinds.inc" |
38 | #include "clang/Basic/DiagnosticLexKinds.inc" |
39 | #include "clang/Basic/DiagnosticParseKinds.inc" |
40 | #include "clang/Basic/DiagnosticASTKinds.inc" |
41 | #include "clang/Basic/DiagnosticCommentKinds.inc" |
42 | #include "clang/Basic/DiagnosticSemaKinds.inc" |
43 | #include "clang/Basic/DiagnosticAnalysisKinds.inc" |
44 | #include "clang/Basic/DiagnosticRefactoringKinds.inc" |
45 | #undef DIAG |
46 | }; |
47 | |
48 | static bool orderByID(const DiagnosticRecord &Left, |
49 | const DiagnosticRecord &Right) { |
50 | return Left.DiagID < Right.DiagID; |
51 | } |
52 | |
53 | const DiagnosticRecord &diagtool::getDiagnosticForID(short DiagID) { |
54 | DiagnosticRecord Key = {nullptr, DiagID, 0}; |
55 | |
56 | const DiagnosticRecord *Result = |
57 | std::lower_bound(std::begin(BuiltinDiagnosticsByID), |
58 | std::end(BuiltinDiagnosticsByID), |
59 | Key, orderByID); |
60 | (0) . __assert_fail ("Result && \"diagnostic not found; table may be out of date\"", "/home/seafit/code_projects/clang_source/clang/tools/diagtool/DiagnosticNames.cpp", 60, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Result && "diagnostic not found; table may be out of date"); |
61 | return *Result; |
62 | } |
63 | |
64 | |
65 | #define GET_DIAG_ARRAYS |
66 | #include "clang/Basic/DiagnosticGroups.inc" |
67 | #undef GET_DIAG_ARRAYS |
68 | |
69 | |
70 | static const GroupRecord OptionTable[] = { |
71 | #define GET_DIAG_TABLE |
72 | #include "clang/Basic/DiagnosticGroups.inc" |
73 | #undef GET_DIAG_TABLE |
74 | }; |
75 | |
76 | llvm::StringRef GroupRecord::getName() const { |
77 | return StringRef(DiagGroupNames + NameOffset + 1, DiagGroupNames[NameOffset]); |
78 | } |
79 | |
80 | GroupRecord::subgroup_iterator GroupRecord::subgroup_begin() const { |
81 | return DiagSubGroups + SubGroups; |
82 | } |
83 | |
84 | GroupRecord::subgroup_iterator GroupRecord::subgroup_end() const { |
85 | return nullptr; |
86 | } |
87 | |
88 | llvm::iterator_range<diagtool::GroupRecord::subgroup_iterator> |
89 | GroupRecord::subgroups() const { |
90 | return llvm::make_range(subgroup_begin(), subgroup_end()); |
91 | } |
92 | |
93 | GroupRecord::diagnostics_iterator GroupRecord::diagnostics_begin() const { |
94 | return DiagArrays + Members; |
95 | } |
96 | |
97 | GroupRecord::diagnostics_iterator GroupRecord::diagnostics_end() const { |
98 | return nullptr; |
99 | } |
100 | |
101 | llvm::iterator_range<diagtool::GroupRecord::diagnostics_iterator> |
102 | GroupRecord::diagnostics() const { |
103 | return llvm::make_range(diagnostics_begin(), diagnostics_end()); |
104 | } |
105 | |
106 | llvm::ArrayRef<GroupRecord> diagtool::getDiagnosticGroups() { |
107 | return llvm::makeArrayRef(OptionTable); |
108 | } |
109 | |