Skip to content

Commit 7468375

Browse files
committed
[ABI] Split TypeReferenceKind from TypeMetadataRecord
1 parent 5e03e33 commit 7468375

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

include/swift/ABI/Metadata.h

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,38 +2295,28 @@ struct TargetTypeMetadataRecord {
22952295
union {
22962296
/// A direct reference to a nominal type descriptor.
22972297
RelativeDirectPointerIntPair<TargetContextDescriptor<Runtime>,
2298-
TypeReferenceKind>
2298+
TypeMetadataRecordKind>
22992299
DirectNominalTypeDescriptor;
23002300

23012301
/// An indirect reference to a nominal type descriptor.
23022302
RelativeDirectPointerIntPair<TargetSignedPointer<Runtime, TargetContextDescriptor<Runtime> * __ptrauth_swift_type_descriptor>,
2303-
TypeReferenceKind>
2303+
TypeMetadataRecordKind>
23042304
IndirectNominalTypeDescriptor;
2305-
2306-
// We only allow a subset of the TypeReferenceKinds here.
2307-
// Should we just acknowledge that this is a different enum?
23082305
};
23092306

23102307
public:
2311-
TypeReferenceKind getTypeKind() const {
2308+
TypeMetadataRecordKind getTypeKind() const {
23122309
return DirectNominalTypeDescriptor.getInt();
23132310
}
23142311

23152312
const TargetContextDescriptor<Runtime> *
23162313
getContextDescriptor() const {
23172314
switch (getTypeKind()) {
2318-
case TypeReferenceKind::DirectTypeDescriptor:
2315+
case TypeMetadataRecordKind::DirectTypeDescriptor:
23192316
return DirectNominalTypeDescriptor.getPointer();
23202317

2321-
case TypeReferenceKind::IndirectTypeDescriptor:
2318+
case TypeMetadataRecordKind::IndirectTypeDescriptor:
23222319
return *IndirectNominalTypeDescriptor.getPointer();
2323-
2324-
// These types (and any others we might add to TypeReferenceKind
2325-
// in the future) are just never used in these lists.
2326-
case TypeReferenceKind::DirectObjCClassName:
2327-
case TypeReferenceKind::IndirectObjCClass:
2328-
case TypeReferenceKind::MetadataKind:
2329-
return nullptr;
23302320
}
23312321

23322322
return nullptr;

include/swift/ABI/MetadataValues.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,19 @@ enum : unsigned {
361361
NumGenericMetadataPrivateDataWords = 16,
362362
};
363363

364-
/// Kinds of type metadata/protocol conformance records.
364+
/// Kinds of type metadata reocrds.
365+
enum class TypeMetadataRecordKind : unsigned {
366+
/// A direct reference to a nominal type descriptor.
367+
DirectTypeDescriptor = 0x00,
368+
369+
/// An indirect reference to a nominal type descriptor.
370+
IndirectTypeDescriptor = 0x01,
371+
372+
First_Kind = DirectTypeDescriptor,
373+
Last_Kind = IndirectTypeDescriptor,
374+
};
375+
376+
/// Kinds of references to type metadata.
365377
enum class TypeReferenceKind : unsigned {
366378
/// The conformance is for a nominal type referenced directly;
367379
/// getTypeDescriptor() points to the type context descriptor.

0 commit comments

Comments
 (0)