Skip to content

Commit 56ee7c5

Browse files
committed
[interop] test, add an Objective-C method invocation exception trapping test
1 parent 7801adf commit 56ee7c5

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-emit-ir %t/test.swift -I %t/Inputs -enable-experimental-cxx-interop | %FileCheck %s
5+
6+
// REQUIRES: objc_interop
7+
// UNSUPPORTED: OS=windows-msvc
8+
9+
//--- Inputs/module.modulemap
10+
module ObjCXXModule {
11+
header "objCXXHeader.h"
12+
}
13+
14+
//--- Inputs/objCXXHeader.h
15+
16+
@interface ObjCInterface
17+
18+
- (void)method;
19+
20+
@end
21+
22+
ObjCInterface * _Nonnull retObjCInterface() noexcept;
23+
24+
//--- test.swift
25+
26+
import ObjCXXModule
27+
28+
func testObjCMethodCall() {
29+
let obj = retObjCInterface();
30+
obj.method();
31+
}
32+
33+
testObjCMethodCall()
34+
35+
// CHECK: define {{.*}} @"$s4test0A14ObjCMethodCallyyF"() #[[#UWATTR:]] personality
36+
// CHECK: invoke void {{.*}} @objc_msgSend
37+
// CHECK-NEXT: to label %[[CONT1:.*]] unwind label %[[UNWIND1:.*]]
38+
// CHECK-EMPTY:
39+
// CHECK-NEXT: [[CONT1]]:
40+
// CHECK: ret
41+
// CHECK-EMPTY:
42+
// CHECK-NEXT: [[UNWIND1]]:
43+
// CHECK-NEXT: landingpad { i8*, i32 }
44+
// CHECK-NEXT: catch i8* null
45+
// CHECK-NEXT: call void @llvm.trap()
46+
// CHECK-NEXT: unreachable
47+
// CHECK-NEXT: }

0 commit comments

Comments
 (0)