1
- // RUN: %target-sil-opt -sil-ownership-verifier-enable-testing -ownership-verifier-textual-error-dumper -enable-sil-verify-all=0 %s -o /dev/null 2>&1 | %FileCheck %s
1
+ // RUN: %target-sil-opt -module-name Swift - sil-ownership-verifier-enable-testing -ownership-verifier-textual-error-dumper -enable-sil-verify-all=0 %s -o /dev/null 2>&1 | %FileCheck %s
2
2
// REQUIRES: asserts
3
3
4
4
sil_stage canonical
@@ -11,6 +11,10 @@ class KlassUser {
11
11
var field: Klass
12
12
}
13
13
14
+ protocol Error {
15
+ var _code: Int { get }
16
+ }
17
+
14
18
sil @use_builtinnativeobject_inguaranteed : $@convention(thin) (@in_guaranteed Builtin.NativeObject) -> ()
15
19
16
20
// CHECK-LABEL: Function: 'simple_error_ref_element_addr'
@@ -136,3 +140,21 @@ bb0(%0 : @owned $KlassUser, %0a : @guaranteed $Klass):
136
140
%3 = load [copy] %result : $*Klass
137
141
return %3 : $Klass
138
142
}
143
+
144
+ // CHECK-LABEL: Error#: 0. Begin Error in Function: 'open_existential_box_interior_pointer_error'
145
+ // CHECK-NEXT: Found outside of lifetime use?!
146
+ // CHECK-NEXT: Value: %1 = begin_borrow %0 : $Error // users: %3, %2
147
+ // CHECK-NEXT: Consuming User: end_borrow %1 : $Error // id: %3
148
+ // CHECK-NEXT: Non Consuming User: %6 = apply %5<@opened("01234567-89AB-CDEF-0123-000000000000") Error>(%2) : $@convention(witness_method: Error) <τ_0_0 where τ_0_0 : Error> (@in_guaranteed τ_0_0) -> Int // type-defs: %2; user: %7
149
+ // CHECK-NEXT: Block: bb0
150
+ // CHECK: Error#: 0. End Error in Function: 'open_existential_box_interior_pointer_error'
151
+ sil [ossa] @open_existential_box_interior_pointer_error : $@convention(thin) (@owned Error) -> Int {
152
+ bb0(%0 : @owned $Error):
153
+ %1 = begin_borrow %0 : $Error
154
+ %2 = open_existential_box %1 : $Error to $*@opened("01234567-89AB-CDEF-0123-000000000000") Error
155
+ end_borrow %1 : $Error
156
+ destroy_value %0 : $Error
157
+ %m = witness_method $@opened("01234567-89AB-CDEF-0123-000000000000") Error, #Error._code!getter, %2 : $*@opened("01234567-89AB-CDEF-0123-000000000000") Error : $@convention(witness_method: Error) <Self: Error> (@in_guaranteed Self) -> Int
158
+ %result = apply %m<@opened("01234567-89AB-CDEF-0123-000000000000") Error>(%2) : $@convention(witness_method: Error) <Self: Error> (@in_guaranteed Self) -> Int
159
+ return %result : $Int
160
+ }
0 commit comments