@@ -24,7 +24,7 @@ const uint16_t VERSION_MAJOR = 0;
24
24
// / API notes file minor version number.
25
25
// /
26
26
// / When the format changes IN ANY WAY, this number should be incremented.
27
- const uint16_t VERSION_MINOR = 26 ; // SwiftCopyable
27
+ const uint16_t VERSION_MINOR = 27 ; // SingleDeclTableKey
28
28
29
29
const uint8_t kSwiftCopyable = 1 ;
30
30
const uint8_t kSwiftNonCopyable = 2 ;
@@ -63,6 +63,10 @@ enum BlockID {
63
63
// / about the method.
64
64
OBJC_METHOD_BLOCK_ID,
65
65
66
+ // / The C++ method data block, which maps C++ (context id, method name) pairs
67
+ // / to information about the method.
68
+ CXX_METHOD_BLOCK_ID,
69
+
66
70
// / The Objective-C selector data block, which maps Objective-C
67
71
// / selector names (# of pieces, identifier IDs) to the selector ID
68
72
// / used in other tables.
@@ -181,6 +185,20 @@ using ObjCMethodDataLayout =
181
185
>;
182
186
} // namespace objc_method_block
183
187
188
+ namespace cxx_method_block {
189
+ enum {
190
+ CXX_METHOD_DATA = 1 ,
191
+ };
192
+
193
+ using CXXMethodDataLayout =
194
+ llvm::BCRecordLayout<CXX_METHOD_DATA, // record ID
195
+ llvm::BCVBR<16 >, // table offset within the blob (see
196
+ // below)
197
+ llvm::BCBlob // map from C++ (context id, name)
198
+ // tuples to C++ method information
199
+ >;
200
+ } // namespace cxx_method_block
201
+
184
202
namespace objc_selector_block {
185
203
enum {
186
204
OBJC_SELECTOR_DATA = 1 ,
@@ -269,11 +287,16 @@ struct ContextTableKey {
269
287
: parentContextID(parentContextID), contextKind(contextKind),
270
288
contextID (contextID) {}
271
289
272
- ContextTableKey (std::optional<Context> context, IdentifierID nameID)
273
- : parentContextID(context ? context->id.Value : (uint32_t )-1),
274
- contextKind(context ? static_cast <uint8_t >(context->kind)
275
- : static_cast<uint8_t>(-1 )),
276
- contextID(nameID) {}
290
+ ContextTableKey (std::optional<ContextID> ParentContextID, ContextKind Kind,
291
+ uint32_t ContextID)
292
+ : parentContextID(ParentContextID ? ParentContextID->Value : -1 ),
293
+ contextKind(static_cast <uint8_t >(Kind)), contextID(ContextID) {}
294
+
295
+ ContextTableKey (std::optional<Context> ParentContext, ContextKind Kind,
296
+ uint32_t ContextID)
297
+ : ContextTableKey(ParentContext ? std::make_optional(ParentContext->id)
298
+ : std::nullopt,
299
+ Kind, ContextID) {}
277
300
278
301
llvm::hash_code hashValue () const {
279
302
return llvm::hash_value (
@@ -286,6 +309,32 @@ inline bool operator==(const ContextTableKey &lhs, const ContextTableKey &rhs) {
286
309
lhs.contextKind == rhs.contextKind && lhs.contextID == rhs.contextID ;
287
310
}
288
311
312
+ // / A stored Objective-C or C++ declaration, represented by the ID of its parent
313
+ // / context, and the name of the declaration.
314
+ struct SingleDeclTableKey {
315
+ uint32_t parentContextID;
316
+ uint32_t nameID;
317
+
318
+ SingleDeclTableKey () : parentContextID(-1 ), nameID(-1 ) {}
319
+
320
+ SingleDeclTableKey (uint32_t ParentContextID, uint32_t NameID)
321
+ : parentContextID(ParentContextID), nameID(NameID) {}
322
+
323
+ SingleDeclTableKey (std::optional<Context> ParentCtx, IdentifierID NameID)
324
+ : parentContextID(ParentCtx ? ParentCtx->id.Value
325
+ : static_cast <uint32_t >(-1 )),
326
+ nameID (NameID) {}
327
+
328
+ llvm::hash_code hashValue () const {
329
+ return llvm::hash_value (std::make_pair (parentContextID, nameID));
330
+ }
331
+ };
332
+
333
+ inline bool operator ==(const SingleDeclTableKey &lhs,
334
+ const SingleDeclTableKey &rhs) {
335
+ return lhs.parentContextID == rhs.parentContextID && lhs.nameID == rhs.nameID ;
336
+ }
337
+
289
338
} // namespace api_notes
290
339
} // namespace clang
291
340
@@ -341,6 +390,29 @@ template <> struct DenseMapInfo<clang::api_notes::ContextTableKey> {
341
390
return lhs == rhs;
342
391
}
343
392
};
393
+
394
+ template <> struct DenseMapInfo <clang::api_notes::SingleDeclTableKey> {
395
+ static inline clang::api_notes::SingleDeclTableKey getEmptyKey () {
396
+ return clang::api_notes::SingleDeclTableKey ();
397
+ }
398
+
399
+ static inline clang::api_notes::SingleDeclTableKey getTombstoneKey () {
400
+ return clang::api_notes::SingleDeclTableKey{
401
+ DenseMapInfo<uint32_t >::getTombstoneKey (),
402
+ DenseMapInfo<uint32_t >::getTombstoneKey ()};
403
+ }
404
+
405
+ static unsigned
406
+ getHashValue (const clang::api_notes::SingleDeclTableKey &value) {
407
+ return value.hashValue ();
408
+ }
409
+
410
+ static bool isEqual (const clang::api_notes::SingleDeclTableKey &lhs,
411
+ const clang::api_notes::SingleDeclTableKey &rhs) {
412
+ return lhs == rhs;
413
+ }
414
+ };
415
+
344
416
} // namespace llvm
345
417
346
418
#endif
0 commit comments