/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/tools/diagtool/DiagnosticNames.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===- DiagnosticNames.h - 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 | | #ifndef LLVM_CLANG_TOOLS_DIAGTOOL_DIAGNOSTICNAMES_H |
10 | | #define LLVM_CLANG_TOOLS_DIAGTOOL_DIAGNOSTICNAMES_H |
11 | | |
12 | | #include "llvm/ADT/ArrayRef.h" |
13 | | #include "llvm/ADT/StringRef.h" |
14 | | #include "llvm/Support/DataTypes.h" |
15 | | |
16 | | namespace diagtool { |
17 | | |
18 | | struct DiagnosticRecord { |
19 | | const char *NameStr; |
20 | | short DiagID; |
21 | | uint8_t NameLen; |
22 | | |
23 | 37.0k | llvm::StringRef getName() const { |
24 | 37.0k | return llvm::StringRef(NameStr, NameLen); |
25 | 37.0k | } |
26 | | |
27 | 0 | bool operator<(const DiagnosticRecord &Other) const { |
28 | 0 | return getName() < Other.getName(); |
29 | 0 | } |
30 | | }; |
31 | | |
32 | | /// Get every diagnostic in the system, sorted by name. |
33 | | llvm::ArrayRef<DiagnosticRecord> getBuiltinDiagnosticsByName(); |
34 | | |
35 | | /// Get a diagnostic by its ID. |
36 | | const DiagnosticRecord &getDiagnosticForID(short DiagID); |
37 | | |
38 | | |
39 | | struct GroupRecord { |
40 | | uint16_t NameOffset; |
41 | | uint16_t Members; |
42 | | uint16_t SubGroups; |
43 | | |
44 | | llvm::StringRef getName() const; |
45 | | |
46 | | template<typename RecordType> |
47 | | class group_iterator { |
48 | | const short *CurrentID; |
49 | | |
50 | | friend struct GroupRecord; |
51 | 42.3k | group_iterator(const short *Start) : CurrentID(Start) { |
52 | 42.3k | if (CurrentID && *CurrentID == -121.1k ) |
53 | 8.68k | CurrentID = nullptr; |
54 | 42.3k | } diagtool::GroupRecord::group_iterator<diagtool::GroupRecord>::group_iterator(short const*) Line | Count | Source | 51 | 18.9k | group_iterator(const short *Start) : CurrentID(Start) { | 52 | 18.9k | if (CurrentID && *CurrentID == -19.46k ) | 53 | 7.45k | CurrentID = nullptr; | 54 | 18.9k | } |
diagtool::GroupRecord::group_iterator<diagtool::DiagnosticRecord>::group_iterator(short const*) Line | Count | Source | 51 | 23.3k | group_iterator(const short *Start) : CurrentID(Start) { | 52 | 23.3k | if (CurrentID && *CurrentID == -111.6k ) | 53 | 1.23k | CurrentID = nullptr; | 54 | 23.3k | } |
|
55 | | |
56 | | public: |
57 | | typedef RecordType value_type; |
58 | | typedef const value_type & reference; |
59 | | typedef const value_type * pointer; |
60 | | typedef std::forward_iterator_tag iterator_category; |
61 | | typedef std::ptrdiff_t difference_type; |
62 | | |
63 | | inline reference operator*() const; |
64 | | inline pointer operator->() const { |
65 | | return &operator*(); |
66 | | } |
67 | | |
68 | 1.61k | inline short getID() const { |
69 | 1.61k | return *CurrentID; |
70 | 1.61k | } |
71 | | |
72 | 16.7k | group_iterator &operator++() { |
73 | 16.7k | ++CurrentID; |
74 | 16.7k | if (*CurrentID == -1) |
75 | 6.59k | CurrentID = nullptr; |
76 | 16.7k | return *this; |
77 | 16.7k | } diagtool::GroupRecord::group_iterator<diagtool::GroupRecord>::operator++() Line | Count | Source | 72 | 3.93k | group_iterator &operator++() { | 73 | 3.93k | ++CurrentID; | 74 | 3.93k | if (*CurrentID == -1) | 75 | 1.41k | CurrentID = nullptr; | 76 | 3.93k | return *this; | 77 | 3.93k | } |
diagtool::GroupRecord::group_iterator<diagtool::DiagnosticRecord>::operator++() Line | Count | Source | 72 | 12.7k | group_iterator &operator++() { | 73 | 12.7k | ++CurrentID; | 74 | 12.7k | if (*CurrentID == -1) | 75 | 5.17k | CurrentID = nullptr; | 76 | 12.7k | return *this; | 77 | 12.7k | } |
|
78 | | |
79 | 3.99k | bool operator==(const group_iterator &Other) const { |
80 | 3.99k | return CurrentID == Other.CurrentID; |
81 | 3.99k | } |
82 | | |
83 | 33.8k | bool operator!=(const group_iterator &Other) const { |
84 | 33.8k | return CurrentID != Other.CurrentID; |
85 | 33.8k | } diagtool::GroupRecord::group_iterator<diagtool::GroupRecord>::operator!=(diagtool::GroupRecord::group_iterator<diagtool::GroupRecord> const&) const Line | Count | Source | 83 | 13.4k | bool operator!=(const group_iterator &Other) const { | 84 | 13.4k | return CurrentID != Other.CurrentID; | 85 | 13.4k | } |
diagtool::GroupRecord::group_iterator<diagtool::DiagnosticRecord>::operator!=(diagtool::GroupRecord::group_iterator<diagtool::DiagnosticRecord> const&) const Line | Count | Source | 83 | 20.4k | bool operator!=(const group_iterator &Other) const { | 84 | 20.4k | return CurrentID != Other.CurrentID; | 85 | 20.4k | } |
|
86 | | }; |
87 | | |
88 | | typedef group_iterator<GroupRecord> subgroup_iterator; |
89 | | subgroup_iterator subgroup_begin() const; |
90 | | subgroup_iterator subgroup_end() const; |
91 | | llvm::iterator_range<subgroup_iterator> subgroups() const; |
92 | | |
93 | | typedef group_iterator<DiagnosticRecord> diagnostics_iterator; |
94 | | diagnostics_iterator diagnostics_begin() const; |
95 | | diagnostics_iterator diagnostics_end() const; |
96 | | llvm::iterator_range<diagnostics_iterator> diagnostics() const; |
97 | | |
98 | 40 | bool operator<(llvm::StringRef Other) const { |
99 | 40 | return getName() < Other; |
100 | 40 | } |
101 | | }; |
102 | | |
103 | | /// Get every diagnostic group in the system, sorted by name. |
104 | | llvm::ArrayRef<GroupRecord> getDiagnosticGroups(); |
105 | | |
106 | | template<> |
107 | | inline GroupRecord::subgroup_iterator::reference |
108 | 2.92k | GroupRecord::subgroup_iterator::operator*() const { |
109 | 2.92k | return getDiagnosticGroups()[*CurrentID]; |
110 | 2.92k | } |
111 | | |
112 | | template<> |
113 | | inline GroupRecord::diagnostics_iterator::reference |
114 | 14.5k | GroupRecord::diagnostics_iterator::operator*() const { |
115 | 14.5k | return getDiagnosticForID(*CurrentID); |
116 | 14.5k | } |
117 | | } // end namespace diagtool |
118 | | |
119 | | #endif |