blob: d72e58281050463722fed8ec01275222a963aab6 [file] [log] [blame]
// RUN: rm -rf %t && mkdir -p %t
// RUN: %build-irgen-test-overlays
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -sdk %S/Inputs -I %t %s -emit-ir | %FileCheck %s
// REQUIRES: CPU=x86_64
// REQUIRES: objc_interop
sil_stage canonical
import Swift
import ObjectiveC
@objc protocol OP {}
// CHECK-LABEL: define{{( protected)?}} swiftcc %TSo8ProtocolC* @protocol_conversion() {{.*}} {
// CHECK: %0 = load i8*, i8** @"\01l_OBJC_PROTOCOL_REFERENCE_$__TtP24objc_protocol_conversion2OP_", align 8
// CHECK: %1 = bitcast i8* %0 to %TSo8ProtocolC*
// CHECK: ret %TSo8ProtocolC* %1
// CHECK: }
sil @protocol_conversion : $@convention(thin) () -> @owned Protocol {
entry:
%p = objc_protocol #OP : $Protocol
return %p : $Protocol
}
// The Protocol class has been hidden in newer ObjC APIs, so when we need its
// metadata, we treat it like a foreign class.
// CHECK-LABEL: define{{( protected)?}} swiftcc %swift.type* @protocol_metatype()
sil @protocol_metatype : $@convention(thin) () -> @thick Protocol.Type {
entry:
// CHECK: call %objc_class* @objc_lookUpClass
// CHECK: call %swift.type* @swift_getObjCClassMetadata
%t = metatype $@thick Protocol.Type
return %t : $@thick Protocol.Type
}