@@ -826,14 +826,16 @@ void IRGenModule::addObjCClass(llvm::Constant *classPtr, bool nonlazy) {
826
826
ObjCNonLazyClasses.push_back (classPtr);
827
827
}
828
828
829
- void IRGenModule::addRuntimeResolvableType (NominalTypeDecl *nominal ) {
829
+ void IRGenModule::addRuntimeResolvableType (GenericTypeDecl *type ) {
830
830
// Collect the nominal type records we emit into a special section.
831
- RuntimeResolvableTypes.push_back (nominal );
831
+ RuntimeResolvableTypes.push_back (type );
832
832
833
- // As soon as the type metadata is available, all the type's conformances
834
- // must be available, too. The reason is that a type (with the help of its
835
- // metadata) can be checked at runtime if it conforms to a protocol.
836
- addLazyConformances (nominal);
833
+ if (auto nominal = dyn_cast<NominalTypeDecl>(type)) {
834
+ // As soon as the type metadata is available, all the type's conformances
835
+ // must be available, too. The reason is that a type (with the help of its
836
+ // metadata) can be checked at runtime if it conforms to a protocol.
837
+ addLazyConformances (nominal);
838
+ }
837
839
}
838
840
839
841
ConstantReference
@@ -2744,41 +2746,49 @@ getObjCClassByNameReference(IRGenModule &IGM, ClassDecl *cls) {
2744
2746
SmallString<64 > objcRuntimeNameBuffer;
2745
2747
auto ref = IGM.getAddrOfGlobalString (
2746
2748
cls->getObjCRuntimeName (objcRuntimeNameBuffer),
2747
- /* willByRelativelyAddressed =*/ true );
2749
+ /* willBeRelativelyAddressed =*/ true );
2748
2750
2749
2751
return TypeEntityReference (kind, ref);
2750
2752
}
2751
2753
2752
2754
TypeEntityReference
2753
- IRGenModule::getTypeEntityReference (NominalTypeDecl *decl) {
2755
+ IRGenModule::getTypeEntityReference (GenericTypeDecl *decl) {
2754
2756
if (auto protocol = dyn_cast<ProtocolDecl>(decl)) {
2755
2757
assert (!protocol->isObjC () && " imported protocols not handled here" );
2756
2758
return getProtocolDescriptorEntityReference (*this , protocol);
2757
2759
}
2758
-
2759
- auto clas = dyn_cast<ClassDecl>(decl);
2760
- if (!clas) {
2761
- return getTypeContextDescriptorEntityReference (*this , decl);
2760
+
2761
+ if (auto opaque = dyn_cast<OpaqueTypeDecl>(decl)) {
2762
+ auto entity = LinkEntity::forOpaqueTypeDescriptor (opaque);
2763
+ IRGen.noteUseOfOpaqueTypeDescriptor (opaque);
2764
+ return getContextDescriptorEntityReference (*this , entity);
2762
2765
}
2763
2766
2764
- switch (clas->getForeignClassKind ()) {
2765
- case ClassDecl::ForeignKind::RuntimeOnly:
2766
- return getObjCClassByNameReference (*this , clas);
2767
+ if (auto nominal = dyn_cast<NominalTypeDecl>(decl)) {
2768
+ auto clas = dyn_cast<ClassDecl>(decl);
2769
+ if (!clas) {
2770
+ return getTypeContextDescriptorEntityReference (*this , nominal);
2771
+ }
2767
2772
2768
- case ClassDecl::ForeignKind::CFType:
2769
- return getTypeContextDescriptorEntityReference (*this , clas);
2773
+ switch (clas->getForeignClassKind ()) {
2774
+ case ClassDecl::ForeignKind::RuntimeOnly:
2775
+ return getObjCClassByNameReference (*this , clas);
2770
2776
2771
- case ClassDecl::ForeignKind::Normal:
2772
- if (hasKnownSwiftMetadata (*this , clas)) {
2777
+ case ClassDecl::ForeignKind::CFType:
2773
2778
return getTypeContextDescriptorEntityReference (*this , clas);
2774
- }
2775
2779
2776
- // Note: we would like to use an Objective-C class reference, but the
2777
- // Darwin linker currently has a bug where it will coalesce these symbols
2778
- // *after* computing a relative offset, causing incorrect relative
2779
- // offsets in the metadata. Therefore, reference Objective-C classes by
2780
- // their runtime names.
2781
- return getObjCClassByNameReference (*this , clas);
2780
+ case ClassDecl::ForeignKind::Normal:
2781
+ if (hasKnownSwiftMetadata (*this , clas)) {
2782
+ return getTypeContextDescriptorEntityReference (*this , clas);
2783
+ }
2784
+
2785
+ // Note: we would like to use an Objective-C class reference, but the
2786
+ // Darwin linker currently has a bug where it will coalesce these symbols
2787
+ // *after* computing a relative offset, causing incorrect relative
2788
+ // offsets in the metadata. Therefore, reference Objective-C classes by
2789
+ // their runtime names.
2790
+ return getObjCClassByNameReference (*this , clas);
2791
+ }
2782
2792
}
2783
2793
llvm_unreachable (" bad foreign type kind" );
2784
2794
}
0 commit comments