Files
swift-mirror/test/IRGen/objc_protocol_conversion.sil
Joe Groff 8cb1175e49 IRGen: Emit public definitions with protected visibility on ELF.
This prevents the linker from trying to emit relative relocations to locally-defined public symbols into dynamic libraries, which gives ld.so heartache.
2016-02-08 13:09:27 -08:00

36 lines
1.1 KiB
Plaintext

// 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
}