-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathcapture_inout.swift
28 lines (25 loc) · 1.07 KB
/
capture_inout.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// RUN: %target-swift-emit-silgen -parse-stdlib %s | %FileCheck %s
typealias Int = Builtin.Int64
// CHECK: sil hidden [ossa] @$s13capture_inout8localFoo1xyBi64_z_tF
// CHECK: bb0([[X_INOUT:%.*]] : $*Builtin.Int64):
// CHECK-NOT: alloc_box
// CHECK: [[FUNC:%.*]] = function_ref [[CLOSURE:@.*]] : $@convention(thin) (@inout_aliasable Builtin.Int64) -> Builtin.Int64
// CHECK: apply [[FUNC]]([[X_INOUT]])
// CHECK: }
// CHECK: sil private [ossa] [[CLOSURE]] : $@convention(thin) (@inout_aliasable Builtin.Int64) -> Builtin.Int64
func localFoo(x: inout Int) {
func bar() -> Int {
return x
}
bar()
}
// CHECK: sil hidden [ossa] @$s13capture_inout7anonFoo1xyBi64_z_tF
// CHECK: bb0([[X_INOUT:%.*]] : $*Builtin.Int64):
// CHECK-NOT: alloc_box
// CHECK: [[FUNC:%.*]] = function_ref [[CLOSURE:@.*]] : $@convention(thin) (@inout_aliasable Builtin.Int64) -> Builtin.Int64
// CHECK: apply [[FUNC]]([[X_INOUT]])
// CHECK: }
// CHECK: sil private [ossa] [[CLOSURE]] : $@convention(thin) (@inout_aliasable Builtin.Int64) -> Builtin.Int64
func anonFoo(x: inout Int) {
{ return x }()
}