@@ -669,153 +669,6 @@ SILLinkage LinkEntity::getLinkage(ForDefinition_t forDefinition) const {
669
669
llvm_unreachable (" bad link entity kind" );
670
670
}
671
671
672
- static bool isAvailableExternally (IRGenModule &IGM, SILFunction *F) {
673
- // TODO
674
- return true ;
675
- }
676
-
677
- static bool isAvailableExternally (IRGenModule &IGM, const DeclContext *dc) {
678
- dc = dc->getModuleScopeContext ();
679
- if (isa<ClangModuleUnit>(dc) ||
680
- dc == IGM.getSILModule ().getAssociatedContext ())
681
- return false ;
682
- return true ;
683
- }
684
-
685
- static bool isAvailableExternally (IRGenModule &IGM, const Decl *decl) {
686
- return isAvailableExternally (IGM, decl->getDeclContext ());
687
- }
688
-
689
- static bool isAvailableExternally (IRGenModule &IGM, Type type) {
690
- if (auto decl = type->getAnyNominal ())
691
- return isAvailableExternally (IGM, decl->getDeclContext ());
692
- return true ;
693
- }
694
-
695
- bool LinkEntity::isAvailableExternally (IRGenModule &IGM) const {
696
- switch (getKind ()) {
697
- case Kind::DispatchThunk:
698
- case Kind::DispatchThunkInitializer:
699
- case Kind::DispatchThunkAllocator: {
700
- auto *decl = getDecl ();
701
-
702
- // Protocol requirements don't have their own access control
703
- if (auto *proto = dyn_cast<ProtocolDecl>(decl->getDeclContext ()))
704
- decl = proto;
705
-
706
- return ::isAvailableExternally (IGM, getDecl ());
707
- }
708
-
709
- case Kind::MethodDescriptor:
710
- case Kind::MethodDescriptorInitializer:
711
- case Kind::MethodDescriptorAllocator: {
712
- auto *decl = getDecl ();
713
-
714
- // Protocol requirements don't have their own access control
715
- if (auto *proto = dyn_cast<ProtocolDecl>(decl->getDeclContext ()))
716
- decl = proto;
717
-
718
- // Method descriptors for internal class initializers can be referenced
719
- // from outside the module.
720
- if (auto *ctor = dyn_cast<ConstructorDecl>(decl)) {
721
- auto *classDecl = cast<ClassDecl>(ctor->getDeclContext ());
722
- if (classDecl->getEffectiveAccess () == AccessLevel::Open)
723
- decl = classDecl;
724
- }
725
-
726
- return ::isAvailableExternally (IGM, getDecl ());
727
- }
728
-
729
- case Kind::ValueWitnessTable:
730
- case Kind::TypeMetadata:
731
- return ::isAvailableExternally (IGM, getType ());
732
-
733
- case Kind::ObjCClass:
734
- case Kind::ObjCMetaclass:
735
- // FIXME: Removing this triggers a linker bug
736
- return true ;
737
-
738
- case Kind::AssociatedConformanceDescriptor:
739
- case Kind::BaseConformanceDescriptor:
740
- case Kind::SwiftMetaclassStub:
741
- case Kind::ClassMetadataBaseOffset:
742
- case Kind::PropertyDescriptor:
743
- case Kind::NominalTypeDescriptor:
744
- case Kind::ProtocolDescriptor:
745
- case Kind::ProtocolRequirementsBaseDescriptor:
746
- case Kind::MethodLookupFunction:
747
- case Kind::OpaqueTypeDescriptor:
748
- case Kind::OpaqueTypeDescriptorAccessor:
749
- case Kind::OpaqueTypeDescriptorAccessorImpl:
750
- case Kind::OpaqueTypeDescriptorAccessorKey:
751
- case Kind::OpaqueTypeDescriptorAccessorVar:
752
- return ::isAvailableExternally (IGM, getDecl ());
753
-
754
- case Kind::AssociatedTypeDescriptor:
755
- return ::isAvailableExternally (
756
- IGM,
757
- (const Decl *)getAssociatedType ()->getProtocol ());
758
-
759
- case Kind::EnumCase:
760
- return ::isAvailableExternally (IGM, getDecl ());
761
-
762
- case Kind::ProtocolWitnessTable:
763
- case Kind::ProtocolConformanceDescriptor:
764
- return ::isAvailableExternally (IGM,
765
- getRootProtocolConformance ()->getDeclContext ());
766
-
767
- case Kind::ProtocolWitnessTablePattern:
768
- case Kind::ObjCClassRef:
769
- case Kind::ModuleDescriptor:
770
- case Kind::ExtensionDescriptor:
771
- case Kind::AnonymousDescriptor:
772
- case Kind::TypeMetadataInstantiationCache:
773
- case Kind::TypeMetadataInstantiationFunction:
774
- case Kind::TypeMetadataSingletonInitializationCache:
775
- case Kind::TypeMetadataCompletionFunction:
776
- case Kind::TypeMetadataPattern:
777
- case Kind::DefaultAssociatedConformanceAccessor:
778
- return false ;
779
- case Kind::DynamicallyReplaceableFunctionKey:
780
- case Kind::DynamicallyReplaceableFunctionVariable:
781
- return true ;
782
-
783
- case Kind::SILFunction:
784
- return ::isAvailableExternally (IGM, getSILFunction ());
785
-
786
- case Kind::FieldOffset: {
787
- return ::isAvailableExternally (IGM,
788
- cast<VarDecl>(getDecl ())
789
- ->getDeclContext ()
790
- ->getInnermostTypeContext ());
791
- }
792
-
793
- case Kind::DifferentiabilityWitness:
794
- return true ;
795
-
796
- case Kind::ObjCMetadataUpdateFunction:
797
- case Kind::ObjCResilientClassStub:
798
- case Kind::ValueWitness:
799
- case Kind::TypeMetadataAccessFunction:
800
- case Kind::TypeMetadataLazyCacheVariable:
801
- case Kind::TypeMetadataDemanglingCacheVariable:
802
- case Kind::ProtocolWitnessTableLazyAccessFunction:
803
- case Kind::ProtocolWitnessTableLazyCacheVariable:
804
- case Kind::AssociatedTypeWitnessTableAccessFunction:
805
- case Kind::GenericProtocolWitnessTableInstantiationFunction:
806
- case Kind::SILGlobalVariable:
807
- case Kind::ReflectionBuiltinDescriptor:
808
- case Kind::ReflectionFieldDescriptor:
809
- case Kind::ReflectionAssociatedTypeDescriptor:
810
- case Kind::CoroutineContinuationPrototype:
811
- case Kind::DynamicallyReplaceableFunctionVariableAST:
812
- case Kind::DynamicallyReplaceableFunctionImpl:
813
- case Kind::DynamicallyReplaceableFunctionKeyAST:
814
- llvm_unreachable (" Relative reference to unsupported link entity" );
815
- }
816
- llvm_unreachable (" bad link entity kind" );
817
- }
818
-
819
672
llvm::Type *LinkEntity::getDefaultDeclarationType (IRGenModule &IGM) const {
820
673
switch (getKind ()) {
821
674
case Kind::ModuleDescriptor:
0 commit comments