/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/tools/diagtool/DiagnosticNames.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===- DiagnosticNames.cpp - Defines a table of all builtin diagnostics ----==// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
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 | 16 | llvm::ArrayRef<DiagnosticRecord> diagtool::getBuiltinDiagnosticsByName() { |
23 | 16 | return llvm::makeArrayRef(BuiltinDiagnosticsByName); |
24 | 16 | } |
25 | | |
26 | | |
27 | | // FIXME: Is it worth having two tables, especially when this one can get |
28 | | // out of sync easily? |
29 | | static const DiagnosticRecord BuiltinDiagnosticsByID[] = { |
30 | | #define DIAG(ENUM, CLASS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \ |
31 | | SHOWINSYSHEADER, SHOWINSYSMACRO, DEFER, 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 | 176k | const DiagnosticRecord &Right) { |
50 | 176k | return Left.DiagID < Right.DiagID; |
51 | 176k | } |
52 | | |
53 | 13.9k | const DiagnosticRecord &diagtool::getDiagnosticForID(short DiagID) { |
54 | 13.9k | DiagnosticRecord Key = {nullptr, DiagID, 0}; |
55 | | |
56 | 13.9k | const DiagnosticRecord *Result = |
57 | 13.9k | llvm::lower_bound(BuiltinDiagnosticsByID, Key, orderByID); |
58 | 13.9k | assert(Result && "diagnostic not found; table may be out of date"); |
59 | 0 | return *Result; |
60 | 13.9k | } |
61 | | |
62 | | |
63 | | #define GET_DIAG_ARRAYS |
64 | | #include "clang/Basic/DiagnosticGroups.inc" |
65 | | #undef GET_DIAG_ARRAYS |
66 | | |
67 | | // Second the table of options, sorted by name for fast binary lookup. |
68 | | static const GroupRecord OptionTable[] = { |
69 | | #define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups, Docs) \ |
70 | | {FlagNameOffset, Members, SubGroups}, |
71 | | #include "clang/Basic/DiagnosticGroups.inc" |
72 | | #undef DIAG_ENTRY |
73 | | }; |
74 | | |
75 | 3.60k | llvm::StringRef GroupRecord::getName() const { |
76 | 3.60k | return StringRef(DiagGroupNames + NameOffset + 1, DiagGroupNames[NameOffset]); |
77 | 3.60k | } |
78 | | |
79 | 9.18k | GroupRecord::subgroup_iterator GroupRecord::subgroup_begin() const { |
80 | 9.18k | return DiagSubGroups + SubGroups; |
81 | 9.18k | } |
82 | | |
83 | 9.18k | GroupRecord::subgroup_iterator GroupRecord::subgroup_end() const { |
84 | 9.18k | return nullptr; |
85 | 9.18k | } |
86 | | |
87 | | llvm::iterator_range<diagtool::GroupRecord::subgroup_iterator> |
88 | 6.34k | GroupRecord::subgroups() const { |
89 | 6.34k | return llvm::make_range(subgroup_begin(), subgroup_end()); |
90 | 6.34k | } |
91 | | |
92 | 11.4k | GroupRecord::diagnostics_iterator GroupRecord::diagnostics_begin() const { |
93 | 11.4k | return DiagArrays + Members; |
94 | 11.4k | } |
95 | | |
96 | 11.4k | GroupRecord::diagnostics_iterator GroupRecord::diagnostics_end() const { |
97 | 11.4k | return nullptr; |
98 | 11.4k | } |
99 | | |
100 | | llvm::iterator_range<diagtool::GroupRecord::diagnostics_iterator> |
101 | 11.4k | GroupRecord::diagnostics() const { |
102 | 11.4k | return llvm::make_range(diagnostics_begin(), diagnostics_end()); |
103 | 11.4k | } |
104 | | |
105 | 2.85k | llvm::ArrayRef<GroupRecord> diagtool::getDiagnosticGroups() { |
106 | 2.85k | return llvm::makeArrayRef(OptionTable); |
107 | 2.85k | } |