@@ -321,43 +321,6 @@ class AssociatedTypeMetadataBuilder : public ReflectionMetadataBuilder {
321
321
}
322
322
};
323
323
324
- class SuperclassMetadataBuilder : public ReflectionMetadataBuilder {
325
- static const uint32_t AssociatedTypeRecordSize = 8 ;
326
-
327
- const ClassDecl *Class;
328
- CanType Superclass;
329
-
330
- void layout () override {
331
- PrettyStackTraceDecl DebugStack (" emitting superclass metadata" ,
332
- Class);
333
-
334
- auto *M = IGM.getSILModule ().getSwiftModule ();
335
-
336
- addTypeRef (M, Class->getDeclaredType ()->getCanonicalType ());
337
- addTypeRef (M, IGM.Context .getAnyObjectType ());
338
-
339
- B.addInt32 (1 );
340
- B.addInt32 (AssociatedTypeRecordSize);
341
-
342
- auto NameGlobal = IGM.getAddrOfStringForTypeRef (" super" );
343
- B.addRelativeAddress (NameGlobal);
344
- addTypeRef (M, Superclass);
345
- }
346
-
347
- public:
348
- SuperclassMetadataBuilder (IRGenModule &IGM,
349
- const ClassDecl *Class,
350
- CanType Superclass)
351
- : ReflectionMetadataBuilder(IGM), Class(Class),
352
- Superclass (Superclass) {}
353
-
354
- llvm::GlobalVariable *emit () {
355
- auto entity = LinkEntity::forReflectionSuperclassDescriptor (Class);
356
- auto section = IGM.getAssociatedTypeMetadataSectionName ();
357
- return ReflectionMetadataBuilder::emit (entity, section);
358
- }
359
- };
360
-
361
324
class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
362
325
const uint32_t fieldRecordSize = 12 ;
363
326
const NominalTypeDecl *NTD;
@@ -465,15 +428,23 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
465
428
}
466
429
467
430
void layout () override {
468
- PrettyStackTraceDecl DebugStack (" emitting field type metadata" , NTD);
469
- auto type = NTD->getDeclaredType ()->getCanonicalType ();
470
- addTypeRef (NTD->getModuleContext (), type);
471
-
472
431
if (NTD->hasClangNode () &&
473
432
!isa<ClassDecl>(NTD) &&
474
433
!isa<ProtocolDecl>(NTD))
475
434
return ;
476
435
436
+ PrettyStackTraceDecl DebugStack (" emitting field type metadata" , NTD);
437
+ auto type = NTD->getDeclaredType ()->getCanonicalType ();
438
+ addTypeRef (NTD->getModuleContext (), type);
439
+
440
+ auto *CD = dyn_cast<ClassDecl>(NTD);
441
+ if (CD && CD->getSuperclass ()) {
442
+ addTypeRef (NTD->getModuleContext (),
443
+ CD->getSuperclass ()->getCanonicalType ());
444
+ } else {
445
+ B.addInt32 (0 );
446
+ }
447
+
477
448
switch (NTD->getKind ()) {
478
449
case DeclKind::Class:
479
450
case DeclKind::Struct:
@@ -992,21 +963,6 @@ void IRGenModule::emitFieldMetadataRecord(const NominalTypeDecl *Decl) {
992
963
993
964
FieldTypeMetadataBuilder builder (*this , Decl);
994
965
builder.emit ();
995
-
996
- // So that -parse-stdlib tests don't need to define an AnyObject
997
- // protocol (which will go away one day anyway).
998
- if (!Context.getProtocol (KnownProtocolKind::AnyObject))
999
- return ;
1000
-
1001
- // If this is a class declaration with a superclass, record the
1002
- // superclass as a special associated type named 'super' on the
1003
- // 'AnyObject' protocol.
1004
- if (auto Superclass = Decl->getDeclaredInterfaceType ()
1005
- ->getSuperclass ()) {
1006
- SuperclassMetadataBuilder builder (*this , cast<ClassDecl>(Decl),
1007
- Superclass->getCanonicalType ());
1008
- builder.emit ();
1009
- }
1010
966
}
1011
967
1012
968
void IRGenModule::emitReflectionMetadataVersion () {
0 commit comments