blob: 3c7866fcb8fe3ebef2ab2078c9398c378a9ca294 [file] [log] [blame]
// RUN: rm -rf %t && mkdir %t
// RUN: %build-irgen-test-overlays
// RUN: %target-swift-frontend -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)?}} %CSo8Protocol* @protocol_conversion() {{.*}} {
// CHECK: %0 = load i8*, i8** @"\01l_OBJC_PROTOCOL_REFERENCE_$__TtP24objc_protocol_conversion2OP_", align 8
// CHECK: %1 = bitcast i8* %0 to %CSo8Protocol*
// CHECK: ret %CSo8Protocol* %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)?}} %swift.type* @protocol_metatype()
sil @protocol_metatype : $@convention(thin) () -> @thick Protocol.Type {
entry:
// CHECK: call %swift.type* @swift_getForeignTypeMetadata
%t = metatype $@thick Protocol.Type
return %t : $@thick Protocol.Type
}