Skip to content

Commit afc963a

Browse files
Merge pull request #30793 from nate-chandler/generic-metadata-prespecialization-components/prepare-for-classes
[prespecialized metadata] Note classes are complete.
2 parents 53ba204 + a1e2fb0 commit afc963a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

include/swift/ABI/Metadata.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,14 @@ struct TargetClassMetadata : public TargetAnyClassMetadata<Runtime> {
12951295
assert(isTypeMetadata());
12961296
}
12971297

1298+
bool isCanonicalStaticallySpecializedGenericMetadata() const {
1299+
auto *description = getDescription();
1300+
if (!description->isGeneric())
1301+
return false;
1302+
1303+
return this->Flags & ClassFlags::IsCanonicalStaticSpecialization;
1304+
}
1305+
12981306
static bool classof(const TargetMetadata<Runtime> *metadata) {
12991307
return metadata->getKind() == MetadataKind::Class;
13001308
}

include/swift/ABI/MetadataValues.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,16 @@ enum class ClassFlags : uint32_t {
265265
UsesSwiftRefcounting = 0x2,
266266

267267
/// Has this class a custom name, specified with the @objc attribute?
268-
HasCustomObjCName = 0x4
268+
HasCustomObjCName = 0x4,
269+
270+
/// Whether this metadata is a specialization of a generic metadata pattern
271+
/// which was created during compilation.
272+
IsStaticSpecialization = 0x8,
273+
274+
/// Whether this metadata is a specialization of a generic metadata pattern
275+
/// which was created during compilation and made to be canonical by
276+
/// modifying the metadata accessor.
277+
IsCanonicalStaticSpecialization = 0x10,
269278
};
270279
inline bool operator&(ClassFlags a, ClassFlags b) {
271280
return (uint32_t(a) & uint32_t(b)) != 0;

stdlib/public/runtime/Metadata.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5512,6 +5512,8 @@ bool Metadata::isCanonicalStaticallySpecializedGenericMetadata() const {
55125512
return metadata->isCanonicalStaticallySpecializedGenericMetadata();
55135513
if (auto *metadata = dyn_cast<EnumMetadata>(this))
55145514
return metadata->isCanonicalStaticallySpecializedGenericMetadata();
5515+
if (auto *metadata = dyn_cast<ClassMetadata>(this))
5516+
return metadata->isCanonicalStaticallySpecializedGenericMetadata();
55155517

55165518
return false;
55175519
}

0 commit comments

Comments
 (0)