@@ -3879,6 +3879,13 @@ struct TargetCanonicalSpecializedMetadatasCachingOnceToken {
38793879 TargetRelativeDirectPointer<Runtime, swift_once_t , /* Nullable*/ false > token;
38803880};
38813881
3882+ template <typename Runtime>
3883+ struct TargetSingletonMetadataPointer {
3884+ TargetRelativeDirectPointer<Runtime, TargetMetadata<Runtime>,
3885+ /* Nullable*/ false >
3886+ metadata;
3887+ };
3888+
38823889template <typename Runtime>
38833890class swift_ptrauth_struct_context_descriptor (TypeContextDescriptor)
38843891 TargetTypeContextDescriptor : public TargetContextDescriptor<Runtime> {
@@ -3931,7 +3938,15 @@ class swift_ptrauth_struct_context_descriptor(TypeContextDescriptor)
39313938 }
39323939
39333940 bool hasCanonicalMetadataPrespecializations () const {
3934- return getTypeContextDescriptorFlags ().hasCanonicalMetadataPrespecializations ();
3941+ return this ->isGeneric () &&
3942+ getTypeContextDescriptorFlags ()
3943+ .hasCanonicalMetadataPrespecializationsOrSingletonMetadataPointer ();
3944+ }
3945+
3946+ bool hasSingletonMetadataPointer () const {
3947+ return !this ->isGeneric () &&
3948+ getTypeContextDescriptorFlags ()
3949+ .hasCanonicalMetadataPrespecializationsOrSingletonMetadataPointer ();
39353950 }
39363951
39373952 bool hasLayoutString () const {
@@ -4123,7 +4138,8 @@ class swift_ptrauth_struct_context_descriptor(ClassDescriptor)
41234138 TargetCanonicalSpecializedMetadatasListEntry<Runtime>,
41244139 TargetCanonicalSpecializedMetadataAccessorsListEntry<Runtime>,
41254140 TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>,
4126- InvertibleProtocolSet> {
4141+ InvertibleProtocolSet,
4142+ TargetSingletonMetadataPointer<Runtime>> {
41274143private:
41284144 using TrailingGenericContextObjects =
41294145 swift::TrailingGenericContextObjects<TargetClassDescriptor<Runtime>,
@@ -4140,7 +4156,8 @@ class swift_ptrauth_struct_context_descriptor(ClassDescriptor)
41404156 TargetCanonicalSpecializedMetadatasListEntry<Runtime>,
41414157 TargetCanonicalSpecializedMetadataAccessorsListEntry<Runtime>,
41424158 TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>,
4143- InvertibleProtocolSet>;
4159+ InvertibleProtocolSet,
4160+ TargetSingletonMetadataPointer<Runtime>>;
41444161
41454162 using TrailingObjects =
41464163 typename TrailingGenericContextObjects::TrailingObjects;
@@ -4170,6 +4187,7 @@ class swift_ptrauth_struct_context_descriptor(ClassDescriptor)
41704187 TargetCanonicalSpecializedMetadataAccessorsListEntry<Runtime>;
41714188 using MetadataCachingOnceToken =
41724189 TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>;
4190+ using SingletonMetadataPointer = TargetSingletonMetadataPointer<Runtime>;
41734191
41744192 using StoredPointer = typename Runtime::StoredPointer;
41754193 using StoredPointerDifference = typename Runtime::StoredPointerDifference;
@@ -4311,6 +4329,10 @@ class swift_ptrauth_struct_context_descriptor(ClassDescriptor)
43114329 return this ->hasCanonicalMetadataPrespecializations () ? 1 : 0 ;
43124330 }
43134331
4332+ size_t numTrailingObjects (OverloadToken<SingletonMetadataPointer>) const {
4333+ return this ->hasSingletonMetadataPointer () ? 1 : 0 ;
4334+ }
4335+
43144336public:
43154337 const TargetRelativeDirectPointer<Runtime, const void , /* nullable*/ true > &
43164338 getResilientSuperclass () const {
@@ -4490,6 +4512,14 @@ class swift_ptrauth_struct_context_descriptor(ClassDescriptor)
44904512 return box->token .get ();
44914513 }
44924514
4515+ TargetMetadata<Runtime> *getSingletonMetadata () const {
4516+ if (!this ->hasSingletonMetadataInitialization ())
4517+ return nullptr ;
4518+
4519+ auto box = this ->template getTrailingObjects <SingletonMetadataPointer>();
4520+ return box->token .get ();
4521+ }
4522+
44934523 // / Retrieve the set of protocols that are inverted by this type's
44944524 // / primary definition.
44954525 // /
@@ -4537,7 +4567,8 @@ class swift_ptrauth_struct_context_descriptor(StructDescriptor)
45374567 TargetCanonicalSpecializedMetadatasListCount<Runtime>,
45384568 TargetCanonicalSpecializedMetadatasListEntry<Runtime>,
45394569 TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>,
4540- InvertibleProtocolSet> {
4570+ InvertibleProtocolSet,
4571+ TargetSingletonMetadataPointer<Runtime>> {
45414572public:
45424573 using ForeignMetadataInitialization =
45434574 TargetForeignMetadataInitialization<Runtime>;
@@ -4551,6 +4582,7 @@ class swift_ptrauth_struct_context_descriptor(StructDescriptor)
45514582 TargetCanonicalSpecializedMetadatasListEntry<Runtime>;
45524583 using MetadataCachingOnceToken =
45534584 TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>;
4585+ using SingletonMetadataPointer = TargetSingletonMetadataPointer<Runtime>;
45544586
45554587private:
45564588 using TrailingGenericContextObjects =
@@ -4561,7 +4593,8 @@ class swift_ptrauth_struct_context_descriptor(StructDescriptor)
45614593 MetadataListCount,
45624594 MetadataListEntry,
45634595 MetadataCachingOnceToken,
4564- InvertibleProtocolSet>;
4596+ InvertibleProtocolSet,
4597+ TargetSingletonMetadataPointer<Runtime>>;
45654598
45664599 using TrailingObjects =
45674600 typename TrailingGenericContextObjects::TrailingObjects;
@@ -4595,6 +4628,10 @@ class swift_ptrauth_struct_context_descriptor(StructDescriptor)
45954628 return this ->hasCanonicalMetadataPrespecializations () ? 1 : 0 ;
45964629 }
45974630
4631+ size_t numTrailingObjects (OverloadToken<SingletonMetadataPointer>) const {
4632+ return this ->hasSingletonMetadataPointer () ? 1 : 0 ;
4633+ }
4634+
45984635public:
45994636 using TrailingGenericContextObjects::getGenericContext;
46004637 using TrailingGenericContextObjects::getGenericContextHeader;
@@ -4648,6 +4685,14 @@ class swift_ptrauth_struct_context_descriptor(StructDescriptor)
46484685 return box->token .get ();
46494686 }
46504687
4688+ TargetMetadata<Runtime> *getSingletonMetadata () const {
4689+ if (!this ->hasSingletonMetadataInitialization ())
4690+ return nullptr ;
4691+
4692+ auto box = this ->template getTrailingObjects <SingletonMetadataPointer>();
4693+ return box->token .get ();
4694+ }
4695+
46514696 // / Retrieve the set of protocols that are inverted by this type's
46524697 // / primary definition.
46534698 // /
@@ -4684,7 +4729,8 @@ class swift_ptrauth_struct_context_descriptor(EnumDescriptor)
46844729 TargetCanonicalSpecializedMetadatasListCount<Runtime>,
46854730 TargetCanonicalSpecializedMetadatasListEntry<Runtime>,
46864731 TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>,
4687- InvertibleProtocolSet> {
4732+ InvertibleProtocolSet,
4733+ TargetSingletonMetadataPointer<Runtime>> {
46884734public:
46894735 using SingletonMetadataInitialization =
46904736 TargetSingletonMetadataInitialization<Runtime>;
@@ -4698,6 +4744,7 @@ class swift_ptrauth_struct_context_descriptor(EnumDescriptor)
46984744 TargetCanonicalSpecializedMetadatasListEntry<Runtime>;
46994745 using MetadataCachingOnceToken =
47004746 TargetCanonicalSpecializedMetadatasCachingOnceToken<Runtime>;
4747+ using SingletonMetadataPointer = TargetSingletonMetadataPointer<Runtime>;
47014748
47024749private:
47034750 using TrailingGenericContextObjects =
@@ -4708,7 +4755,8 @@ class swift_ptrauth_struct_context_descriptor(EnumDescriptor)
47084755 MetadataListCount,
47094756 MetadataListEntry,
47104757 MetadataCachingOnceToken,
4711- InvertibleProtocolSet>;
4758+ InvertibleProtocolSet,
4759+ TargetSingletonMetadataPointer<Runtime>>;
47124760
47134761 using TrailingObjects =
47144762 typename TrailingGenericContextObjects::TrailingObjects;
@@ -4742,6 +4790,10 @@ class swift_ptrauth_struct_context_descriptor(EnumDescriptor)
47424790 return this ->hasCanonicalMetadataPrespecializations () ? 1 : 0 ;
47434791 }
47444792
4793+ size_t numTrailingObjects (OverloadToken<SingletonMetadataPointer>) const {
4794+ return this ->hasSingletonMetadataPointer () ? 1 : 0 ;
4795+ }
4796+
47454797public:
47464798 using TrailingGenericContextObjects::getGenericContext;
47474799 using TrailingGenericContextObjects::getGenericContextHeader;
@@ -4809,6 +4861,14 @@ class swift_ptrauth_struct_context_descriptor(EnumDescriptor)
48094861 return box->token .get ();
48104862 }
48114863
4864+ TargetMetadata<Runtime> *getSingletonMetadata () const {
4865+ if (!this ->hasSingletonMetadataInitialization ())
4866+ return nullptr ;
4867+
4868+ auto box = this ->template getTrailingObjects <SingletonMetadataPointer>();
4869+ return box->token .get ();
4870+ }
4871+
48124872 // / Retrieve the set of protocols that are inverted by this type's
48134873 // / primary definition.
48144874 // /
0 commit comments