mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
several more places to use getOrCreateHelperFunction. This means that several of these places are now emitting shared functions rather than private ones, which I've verified is okay. There are some other places where privacy is still unfortunately necessary. I've also fixed the name of the store-extra-inhabitants helper function to say "store" instead of "get", which is longstanding (but harmless because it's private). Fixes rdar://66707994.
60 lines
2.1 KiB
Plaintext
60 lines
2.1 KiB
Plaintext
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %{python} %utils/chex.py < %s > %t/keypaths_objc.sil
|
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir %t/keypaths_objc.sil | %FileCheck %t/keypaths_objc.sil --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
|
|
// REQUIRES: objc_interop
|
|
|
|
import Swift
|
|
import Foundation
|
|
|
|
class C: NSObject {
|
|
@objc dynamic var x: NSString { get }
|
|
@_hasStorage final var stored: Int
|
|
override init()
|
|
}
|
|
|
|
sil_vtable C {}
|
|
|
|
sil @x_get : $@convention(thin) (@in_guaranteed C) -> @out NSString
|
|
|
|
// CHECK: [[KEYPATH_A:@keypath(\..*)?]] = private global
|
|
// -- computed, get-only, function-instantiated identifier
|
|
// CHECK-SAME: <i32 0x0200_0001>,
|
|
// CHECK-SAME: i8* (i8*)* [[SELECTOR_FN:@[A-Za-z0-9_.]+]] to
|
|
|
|
// CHECK: [[KEYPATH_B:@keypath(\..*)?]] = private global
|
|
// -- class mutable stored property with indirect offset
|
|
// CHECK-SAME: <i32 0x03fffffd>,
|
|
// CHECK-SAME: @"$s13keypaths_objc1CC6storedSivpWvd"
|
|
|
|
// CHECK-LABEL: define swiftcc void @objc_only_property()
|
|
sil @objc_only_property : $@convention(thin) () -> () {
|
|
entry:
|
|
// CHECK: call %swift.refcounted* @swift_getKeyPath({{.*}} [[KEYPATH_A]]
|
|
%a = keypath $KeyPath<C, NSString>, (objc "x"; root $C; gettable_property $NSString, id #C.x!getter.foreign, getter @x_get : $@convention(thin) (@in_guaranteed C) -> @out NSString)
|
|
unreachable
|
|
}
|
|
|
|
sil hidden @$s13keypaths_objc1CC1xSo8NSStringCvgTo : $@convention(objc_method) (@guaranteed C) -> NSString {
|
|
entry(%0 : $C):
|
|
unreachable
|
|
}
|
|
|
|
sil hidden @$s13keypaths_objc1CCACycfcTo : $@convention(objc_method) (@objc_metatype C.Type) -> @owned C {
|
|
entry(%0 : $@objc_metatype C.Type):
|
|
unreachable
|
|
}
|
|
|
|
// CHECK: define linkonce_odr hidden i8* [[SELECTOR_FN]]
|
|
// CHECK-NEXT: entry:
|
|
// CHECK-NEXT: %1 = load {{.*}}selector(x)
|
|
// CHECK-NEXT: ret i8* %1
|
|
|
|
// CHECK-LABEL: define swiftcc void @objc_stored_property()
|
|
sil @objc_stored_property : $@convention(thin) () -> () {
|
|
entry:
|
|
// CHECK: call %swift.refcounted* @swift_getKeyPath({{.*}} [[KEYPATH_B]]
|
|
%b = keypath $KeyPath<C, Int>, (objc "stored"; root $C; stored_property #C.stored : $Int)
|
|
unreachable
|
|
}
|