clang  14.0.0git
APINotesFormat.h
Go to the documentation of this file.
1 //===-- APINotesWriter.h - API Notes Writer ---------------------*- C++ -*-===//
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_LIB_APINOTES_APINOTESFORMAT_H
10 #define LLVM_CLANG_LIB_APINOTES_APINOTESFORMAT_H
11 
12 #include "llvm/ADT/PointerEmbeddedInt.h"
13 #include "llvm/Bitcode/BitcodeConvenience.h"
14 
15 namespace clang {
16 namespace api_notes {
17 /// Magic number for API notes files.
18 const unsigned char API_NOTES_SIGNATURE[] = {0xE2, 0x9C, 0xA8, 0x01};
19 
20 /// API notes file major version number.
21 const uint16_t VERSION_MAJOR = 0;
22 
23 /// API notes file minor version number.
24 ///
25 /// When the format changes IN ANY WAY, this number should be incremented.
26 const uint16_t VERSION_MINOR = 24; // EnumExtensibility + FlagEnum
27 
28 using IdentifierID = llvm::PointerEmbeddedInt<unsigned, 31>;
29 using IdentifierIDField = llvm::BCVBR<16>;
30 
31 using SelectorID = llvm::PointerEmbeddedInt<unsigned, 31>;
32 using SelectorIDField = llvm::BCVBR<16>;
33 
34 /// The various types of blocks that can occur within a API notes file.
35 ///
36 /// These IDs must \em not be renumbered or reordered without incrementing
37 /// VERSION_MAJOR.
38 enum BlockID {
39  /// The control block, which contains all of the information that needs to
40  /// be validated prior to committing to loading the API notes file.
41  ///
42  /// \sa control_block
43  CONTROL_BLOCK_ID = llvm::bitc::FIRST_APPLICATION_BLOCKID,
44 
45  /// The identifier data block, which maps identifier strings to IDs.
47 
48  /// The Objective-C context data block, which contains information about
49  /// Objective-C classes and protocols.
51 
52  /// The Objective-C property data block, which maps Objective-C
53  /// (class name, property name) pairs to information about the
54  /// property.
56 
57  /// The Objective-C property data block, which maps Objective-C
58  /// (class name, selector, is_instance_method) tuples to information
59  /// about the method.
61 
62  /// The Objective-C selector data block, which maps Objective-C
63  /// selector names (# of pieces, identifier IDs) to the selector ID
64  /// used in other tables.
66 
67  /// The global variables data block, which maps global variable names to
68  /// information about the global variable.
70 
71  /// The (global) functions data block, which maps global function names to
72  /// information about the global function.
74 
75  /// The tag data block, which maps tag names to information about
76  /// the tags.
78 
79  /// The typedef data block, which maps typedef names to information about
80  /// the typedefs.
82 
83  /// The enum constant data block, which maps enumerator names to
84  /// information about the enumerators.
86 };
87 
88 namespace control_block {
89 // These IDs must \em not be renumbered or reordered without incrementing
90 // VERSION_MAJOR.
91 enum {
92  METADATA = 1,
96 };
97 
98 using MetadataLayout =
99  llvm::BCRecordLayout<METADATA, // ID
100  llvm::BCFixed<16>, // Module format major version
101  llvm::BCFixed<16> // Module format minor version
102  >;
103 
104 using ModuleNameLayout = llvm::BCRecordLayout<MODULE_NAME,
105  llvm::BCBlob // Module name
106  >;
107 
108 using ModuleOptionsLayout =
109  llvm::BCRecordLayout<MODULE_OPTIONS,
110  llvm::BCFixed<1> // SwiftInferImportAsMember
111  >;
112 
113 using SourceFileLayout = llvm::BCRecordLayout<SOURCE_FILE,
114  llvm::BCVBR<16>, // file size
115  llvm::BCVBR<16> // creation time
116  >;
117 } // namespace control_block
118 
119 namespace identifier_block {
120 enum {
122 };
123 
124 using IdentifierDataLayout = llvm::BCRecordLayout<
125  IDENTIFIER_DATA, // record ID
126  llvm::BCVBR<16>, // table offset within the blob (see below)
127  llvm::BCBlob // map from identifier strings to decl kinds / decl IDs
128  >;
129 } // namespace identifier_block
130 
131 namespace objc_context_block {
132 enum {
135 };
136 
137 using ObjCContextIDLayout =
138  llvm::BCRecordLayout<OBJC_CONTEXT_ID_DATA, // record ID
139  llvm::BCVBR<16>, // table offset within the blob (see
140  // below)
141  llvm::BCBlob // map from ObjC class names/protocol (as
142  // IDs) to context IDs
143  >;
144 
145 using ObjCContextInfoLayout = llvm::BCRecordLayout<
146  OBJC_CONTEXT_INFO_DATA, // record ID
147  llvm::BCVBR<16>, // table offset within the blob (see below)
148  llvm::BCBlob // map from ObjC context IDs to context information.
149  >;
150 } // namespace objc_context_block
151 
152 namespace objc_property_block {
153 enum {
155 };
156 
157 using ObjCPropertyDataLayout = llvm::BCRecordLayout<
158  OBJC_PROPERTY_DATA, // record ID
159  llvm::BCVBR<16>, // table offset within the blob (see below)
160  llvm::BCBlob // map from ObjC (class name, property name) pairs to
161  // ObjC property information
162  >;
163 } // namespace objc_property_block
164 
165 namespace objc_method_block {
166 enum {
168 };
169 
170 using ObjCMethodDataLayout =
171  llvm::BCRecordLayout<OBJC_METHOD_DATA, // record ID
172  llvm::BCVBR<16>, // table offset within the blob (see
173  // below)
174  llvm::BCBlob // map from ObjC (class names, selector,
175  // is-instance-method) tuples to ObjC
176  // method information
177  >;
178 } // namespace objc_method_block
179 
180 namespace objc_selector_block {
181 enum {
183 };
184 
186  llvm::BCRecordLayout<OBJC_SELECTOR_DATA, // record ID
187  llvm::BCVBR<16>, // table offset within the blob (see
188  // below)
189  llvm::BCBlob // map from (# pieces, identifier IDs) to
190  // Objective-C selector ID.
191  >;
192 } // namespace objc_selector_block
193 
194 namespace global_variable_block {
195 enum { GLOBAL_VARIABLE_DATA = 1 };
196 
197 using GlobalVariableDataLayout = llvm::BCRecordLayout<
198  GLOBAL_VARIABLE_DATA, // record ID
199  llvm::BCVBR<16>, // table offset within the blob (see below)
200  llvm::BCBlob // map from name to global variable information
201  >;
202 } // namespace global_variable_block
203 
204 namespace global_function_block {
205 enum { GLOBAL_FUNCTION_DATA = 1 };
206 
207 using GlobalFunctionDataLayout = llvm::BCRecordLayout<
208  GLOBAL_FUNCTION_DATA, // record ID
209  llvm::BCVBR<16>, // table offset within the blob (see below)
210  llvm::BCBlob // map from name to global function information
211  >;
212 } // namespace global_function_block
213 
214 namespace tag_block {
215 enum { TAG_DATA = 1 };
216 
217 using TagDataLayout =
218  llvm::BCRecordLayout<TAG_DATA, // record ID
219  llvm::BCVBR<16>, // table offset within the blob (see
220  // below)
221  llvm::BCBlob // map from name to tag information
222  >;
223 }; // namespace tag_block
224 
225 namespace typedef_block {
226 enum { TYPEDEF_DATA = 1 };
227 
228 using TypedefDataLayout =
229  llvm::BCRecordLayout<TYPEDEF_DATA, // record ID
230  llvm::BCVBR<16>, // table offset within the blob (see
231  // below)
232  llvm::BCBlob // map from name to typedef information
233  >;
234 }; // namespace typedef_block
235 
236 namespace enum_constant_block {
237 enum { ENUM_CONSTANT_DATA = 1 };
238 
240  llvm::BCRecordLayout<ENUM_CONSTANT_DATA, // record ID
241  llvm::BCVBR<16>, // table offset within the blob (see
242  // below)
243  llvm::BCBlob // map from name to enumerator information
244  >;
245 } // namespace enum_constant_block
246 
247 /// A stored Objective-C selector.
249  unsigned NumPieces;
251 };
252 } // namespace api_notes
253 } // namespace clang
254 
255 #endif
clang::api_notes::TAG_BLOCK_ID
@ TAG_BLOCK_ID
The tag data block, which maps tag names to information about the tags.
Definition: APINotesFormat.h:77
clang::api_notes::IDENTIFIER_BLOCK_ID
@ IDENTIFIER_BLOCK_ID
The identifier data block, which maps identifier strings to IDs.
Definition: APINotesFormat.h:46
clang::api_notes::CONTROL_BLOCK_ID
@ CONTROL_BLOCK_ID
The control block, which contains all of the information that needs to be validated prior to committi...
Definition: APINotesFormat.h:43
clang::api_notes::objc_method_block::OBJC_METHOD_DATA
@ OBJC_METHOD_DATA
Definition: APINotesFormat.h:167
llvm::SmallVector< IdentifierID, 2 >
clang::api_notes::VERSION_MINOR
const uint16_t VERSION_MINOR
API notes file minor version number.
Definition: APINotesFormat.h:26
clang::api_notes::objc_context_block::ObjCContextInfoLayout
llvm::BCRecordLayout< OBJC_CONTEXT_INFO_DATA, llvm::BCVBR< 16 >, llvm::BCBlob > ObjCContextInfoLayout
Definition: APINotesFormat.h:149
clang::api_notes::global_variable_block::GLOBAL_VARIABLE_DATA
@ GLOBAL_VARIABLE_DATA
Definition: APINotesFormat.h:195
clang::api_notes::ENUM_CONSTANT_BLOCK_ID
@ ENUM_CONSTANT_BLOCK_ID
The enum constant data block, which maps enumerator names to information about the enumerators.
Definition: APINotesFormat.h:85
clang::api_notes::tag_block::TAG_DATA
@ TAG_DATA
Definition: APINotesFormat.h:215
clang::api_notes::objc_selector_block::OBJC_SELECTOR_DATA
@ OBJC_SELECTOR_DATA
Definition: APINotesFormat.h:182
clang::api_notes::enum_constant_block::EnumConstantDataLayout
llvm::BCRecordLayout< ENUM_CONSTANT_DATA, llvm::BCVBR< 16 >, llvm::BCBlob > EnumConstantDataLayout
Definition: APINotesFormat.h:244
clang::api_notes::OBJC_PROPERTY_BLOCK_ID
@ OBJC_PROPERTY_BLOCK_ID
The Objective-C property data block, which maps Objective-C (class name, property name) pairs to info...
Definition: APINotesFormat.h:55
clang::api_notes::control_block::ModuleNameLayout
llvm::BCRecordLayout< MODULE_NAME, llvm::BCBlob > ModuleNameLayout
Definition: APINotesFormat.h:106
clang::api_notes::objc_selector_block::ObjCSelectorDataLayout
llvm::BCRecordLayout< OBJC_SELECTOR_DATA, llvm::BCVBR< 16 >, llvm::BCBlob > ObjCSelectorDataLayout
Definition: APINotesFormat.h:191
clang::api_notes::identifier_block::IDENTIFIER_DATA
@ IDENTIFIER_DATA
Definition: APINotesFormat.h:121
clang::api_notes::OBJC_METHOD_BLOCK_ID
@ OBJC_METHOD_BLOCK_ID
The Objective-C property data block, which maps Objective-C (class name, selector,...
Definition: APINotesFormat.h:60
clang::api_notes::GLOBAL_FUNCTION_BLOCK_ID
@ GLOBAL_FUNCTION_BLOCK_ID
The (global) functions data block, which maps global function names to information about the global f...
Definition: APINotesFormat.h:73
clang::api_notes::control_block::MODULE_NAME
@ MODULE_NAME
Definition: APINotesFormat.h:93
clang::api_notes::TYPEDEF_BLOCK_ID
@ TYPEDEF_BLOCK_ID
The typedef data block, which maps typedef names to information about the typedefs.
Definition: APINotesFormat.h:81
clang::api_notes::control_block::MODULE_OPTIONS
@ MODULE_OPTIONS
Definition: APINotesFormat.h:94
clang::api_notes::control_block::MetadataLayout
llvm::BCRecordLayout< METADATA, llvm::BCFixed< 16 >, llvm::BCFixed< 16 > > MetadataLayout
Definition: APINotesFormat.h:102
clang::api_notes::OBJC_SELECTOR_BLOCK_ID
@ OBJC_SELECTOR_BLOCK_ID
The Objective-C selector data block, which maps Objective-C selector names (# of pieces,...
Definition: APINotesFormat.h:65
clang::api_notes::BlockID
BlockID
The various types of blocks that can occur within a API notes file.
Definition: APINotesFormat.h:38
clang::api_notes::OBJC_CONTEXT_BLOCK_ID
@ OBJC_CONTEXT_BLOCK_ID
The Objective-C context data block, which contains information about Objective-C classes and protocol...
Definition: APINotesFormat.h:50
clang::api_notes::control_block::SOURCE_FILE
@ SOURCE_FILE
Definition: APINotesFormat.h:95
clang::api_notes::objc_method_block::ObjCMethodDataLayout
llvm::BCRecordLayout< OBJC_METHOD_DATA, llvm::BCVBR< 16 >, llvm::BCBlob > ObjCMethodDataLayout
Definition: APINotesFormat.h:177
clang::api_notes::global_function_block::GLOBAL_FUNCTION_DATA
@ GLOBAL_FUNCTION_DATA
Definition: APINotesFormat.h:205
clang::api_notes::global_function_block::GlobalFunctionDataLayout
llvm::BCRecordLayout< GLOBAL_FUNCTION_DATA, llvm::BCVBR< 16 >, llvm::BCBlob > GlobalFunctionDataLayout
Definition: APINotesFormat.h:211
clang::api_notes::VERSION_MAJOR
const uint16_t VERSION_MAJOR
API notes file major version number.
Definition: APINotesFormat.h:21
clang::api_notes::identifier_block::IdentifierDataLayout
llvm::BCRecordLayout< IDENTIFIER_DATA, llvm::BCVBR< 16 >, llvm::BCBlob > IdentifierDataLayout
Definition: APINotesFormat.h:128
clang::api_notes::typedef_block::TYPEDEF_DATA
@ TYPEDEF_DATA
Definition: APINotesFormat.h:226
clang::api_notes::objc_context_block::OBJC_CONTEXT_ID_DATA
@ OBJC_CONTEXT_ID_DATA
Definition: APINotesFormat.h:133
clang::api_notes::StoredObjCSelector::NumPieces
unsigned NumPieces
Definition: APINotesFormat.h:249
clang::api_notes::enum_constant_block::ENUM_CONSTANT_DATA
@ ENUM_CONSTANT_DATA
Definition: APINotesFormat.h:237
clang::api_notes::typedef_block::TypedefDataLayout
llvm::BCRecordLayout< TYPEDEF_DATA, llvm::BCVBR< 16 >, llvm::BCBlob > TypedefDataLayout
Definition: APINotesFormat.h:233
clang::api_notes::objc_property_block::ObjCPropertyDataLayout
llvm::BCRecordLayout< OBJC_PROPERTY_DATA, llvm::BCVBR< 16 >, llvm::BCBlob > ObjCPropertyDataLayout
Definition: APINotesFormat.h:162
clang::api_notes::StoredObjCSelector
A stored Objective-C selector.
Definition: APINotesFormat.h:248
clang::api_notes::IdentifierIDField
llvm::BCVBR< 16 > IdentifierIDField
Definition: APINotesFormat.h:29
clang::api_notes::objc_property_block::OBJC_PROPERTY_DATA
@ OBJC_PROPERTY_DATA
Definition: APINotesFormat.h:154
clang::api_notes::GLOBAL_VARIABLE_BLOCK_ID
@ GLOBAL_VARIABLE_BLOCK_ID
The global variables data block, which maps global variable names to information about the global var...
Definition: APINotesFormat.h:69
clang::api_notes::control_block::ModuleOptionsLayout
llvm::BCRecordLayout< MODULE_OPTIONS, llvm::BCFixed< 1 > > ModuleOptionsLayout
Definition: APINotesFormat.h:111
clang
Definition: CalledOnceCheck.h:17
clang::api_notes::SelectorIDField
llvm::BCVBR< 16 > SelectorIDField
Definition: APINotesFormat.h:32
clang::api_notes::API_NOTES_SIGNATURE
const unsigned char API_NOTES_SIGNATURE[]
Magic number for API notes files.
Definition: APINotesFormat.h:18
clang::api_notes::tag_block::TagDataLayout
llvm::BCRecordLayout< TAG_DATA, llvm::BCVBR< 16 >, llvm::BCBlob > TagDataLayout
Definition: APINotesFormat.h:222
clang::api_notes::StoredObjCSelector::Identifiers
llvm::SmallVector< IdentifierID, 2 > Identifiers
Definition: APINotesFormat.h:250
clang::api_notes::SelectorID
llvm::PointerEmbeddedInt< unsigned, 31 > SelectorID
Definition: APINotesFormat.h:31
clang::api_notes::objc_context_block::ObjCContextIDLayout
llvm::BCRecordLayout< OBJC_CONTEXT_ID_DATA, llvm::BCVBR< 16 >, llvm::BCBlob > ObjCContextIDLayout
Definition: APINotesFormat.h:143
clang::api_notes::control_block::METADATA
@ METADATA
Definition: APINotesFormat.h:92
clang::api_notes::objc_context_block::OBJC_CONTEXT_INFO_DATA
@ OBJC_CONTEXT_INFO_DATA
Definition: APINotesFormat.h:134
clang::api_notes::control_block::SourceFileLayout
llvm::BCRecordLayout< SOURCE_FILE, llvm::BCVBR< 16 >, llvm::BCVBR< 16 > > SourceFileLayout
Definition: APINotesFormat.h:116
clang::api_notes::global_variable_block::GlobalVariableDataLayout
llvm::BCRecordLayout< GLOBAL_VARIABLE_DATA, llvm::BCVBR< 16 >, llvm::BCBlob > GlobalVariableDataLayout
Definition: APINotesFormat.h:201
clang::api_notes::IdentifierID
llvm::PointerEmbeddedInt< unsigned, 31 > IdentifierID
Definition: APINotesFormat.h:28