mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The use of 'nocapture' for parameters and return values is incorrect for C++ types, as they can actually capture a pointer into its own value (e.g. std::string in libstdc++) rdar://115062687
27 lines
1015 B
Plaintext
27 lines
1015 B
Plaintext
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize
|
|
|
|
import Swift
|
|
|
|
sil @take_any_error : $@convention(thin) <T: Error> (@in T) -> ()
|
|
|
|
// CHECK-LABEL: swiftcc void @test(ptr
|
|
sil @test : $@convention(thin) (@in Error) -> () {
|
|
entry(%0 : $*Error):
|
|
// CHECK: [[ERROR_METADATA:%.*]] = call {{.*}}@"$ss5Error_pMD"
|
|
// CHECK-NEXT: call swiftcc void @take_any_error(ptr noalias %0, ptr [[ERROR_METADATA]], ptr @"$ss5ErrorWS")
|
|
// CHECK-NEXT: ret void
|
|
%take = function_ref @take_any_error : $@convention(thin) <T: Error> (@in T) -> ()
|
|
apply %take<Error>(%0) : $@convention(thin) <T: Error> (@in T) -> ()
|
|
%ret = tuple ()
|
|
return %ret : $()
|
|
}
|
|
|
|
sil @partial_apply_test : $@convention(thin) (@in Error) -> () {
|
|
entry(%0 : $*Error):
|
|
%take = function_ref @take_any_error : $@convention(thin) <T: Error> (@in T) -> ()
|
|
%fn = partial_apply %take<Error>(%0) : $@convention(thin) <T: Error> (@in T) -> ()
|
|
release_value %fn : $@callee_owned () ->()
|
|
%ret = tuple ()
|
|
return %ret : $()
|
|
}
|