Skip to content

Commit 19d3a4d

Browse files
committed
Test case for withoutActuallyEscaping of blocks
rdar://38689227
1 parent d9f5232 commit 19d3a4d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %target-swift-frontend -module-name without_actually_escaping -emit-silgen -enable-sil-ownership %s | %FileCheck %s
2+
3+
// REQUIRES: objc_interop
4+
5+
import Foundation
6+
7+
typealias Callback = @convention(block) () -> Void
8+
9+
// CHECK-LABEL: sil {{.*}} @$S25without_actually_escaping9testBlock5blockyyyXB_tF
10+
// CHECK: bb0([[ARG:%.*]] : @guaranteed $@convention(block) @noescape () -> ()):
11+
// CHECK: [[C1:%.*]] = copy_block [[ARG]]
12+
// CHECK: [[B1:%.*]] = begin_borrow [[C1]]
13+
// CHECK: [[C2:%.*]] = copy_value [[B1]]
14+
// CHECK: [[CVT:%.*]] = convert_function [[C2]] : $@convention(block) @noescape () -> () to $@convention(block) () -> ()
15+
// CHECK: [[B2:%.*]] = begin_borrow [[CVT]]
16+
// CHECK: [[FN:%.*]] = function_ref @$S25without_actually_escaping9testBlock5blockyyyXB_tFyyyXBXEfU_
17+
// CHECK: apply [[FN]]([[B2]])
18+
// CHECK: end_borrow [[B2]] from [[CVT]]
19+
// CHECK: destroy_value [[CVT]]
20+
// CHECK: end_borrow [[B1]] from [[C1]]
21+
// CHECK: destroy_value [[C1]]
22+
// CHECK: return
23+
24+
func testBlock(block: Callback) {
25+
withoutActuallyEscaping(block) { $0() }
26+
}

0 commit comments

Comments
 (0)