Skip to content

Commit a259a20

Browse files
committed
[interop] test, add test to ensure that a protocol conformance witness can trap on uncaught exceptions
1 parent fd3e784 commit a259a20

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/Interop/Cxx/exceptions/trap-on-exception-irgen-itanium.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,26 @@ func testCFuncPtrCall() {
129129
funcPtr()
130130
}
131131

132+
protocol TestMethodProtocol {
133+
func method(_ x: CInt) -> CInt
134+
}
135+
136+
extension TestClass: TestMethodProtocol {
137+
}
138+
139+
func testProtocolConformanceThunkInvoke() {
140+
let v = TestClass()
141+
let p: TestMethodProtocol = v
142+
let _ = p.method(2)
143+
}
144+
132145
let _ = testFreeFunctionNoThrowOnly()
133146
let _ = testFreeFunctionCalls()
134147
let _ = testMethodCalls()
135148
testTemplateCalls()
136149
testFuncPtrCall()
137150
testCFuncPtrCall()
151+
testProtocolConformanceThunkInvoke()
138152

139153
// CHECK: define {{.*}} @"$s4test0A23FreeFunctionNoThrowOnlys5Int32VyF"() #[[#SWIFTMETA:]] {
140154
// CHECK-NEXT: :
@@ -222,6 +236,23 @@ testCFuncPtrCall()
222236
// CHECK: [[CONT21]]:
223237
// CHECK-NEXT: ret void
224238

239+
// CHECK: define {{.*}} @"$sSo9TestClassV4test0A14MethodProtocolA2cDP6methodys5Int32VAHFTW"({{.*}}) #[[#SWIFTUWMETA]] personality
240+
// CHECK: invoke i32 @_ZNK9TestClass6methodEi({{.*}})
241+
// CHECK-NEXT: to label %[[CONT30:.*]] unwind label %[[UNWIND30:.*]]
242+
// CHECK: [[CONT30]]:
243+
// CHECK-NEXT: ret i32
244+
// CHECK-EMPTY:
245+
// CHECK-NEXT: [[UNWIND30]]:
246+
// CHECK-NEXT: %4 = landingpad { i8*, i32 }
247+
// CHECK-NEXT: catch i8* null
248+
// CHECK-NEXT: call void @llvm.trap()
249+
// CHECK-NEXT: unreachable
250+
// CHECK-NEXT: }
251+
252+
// CHECK: define {{.*}} @"$s4test0A30ProtocolConformanceThunkInvokeyyF"() #[[#SWIFTMETA]]
253+
// CHECK-NOT: invoke
254+
// CHECK: }
255+
225256
// CHECK: i32 @__gxx_personality_v0(...)
226257

227258
// CHECK: attributes #[[#SWIFTMETA]] = {

0 commit comments

Comments
 (0)