xref: /llvm-project/clang/test/CodeGen/exceptions.c (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-strict-prototypes -emit-llvm -o - %s -fexceptions -fblocks | FileCheck %s
2 // RUN: %clang_cc1 -triple armv7-apple-unknown -Wno-strict-prototypes -emit-llvm -o - %s -fexceptions -exception-model=sjlj -fblocks | FileCheck %s -check-prefix=CHECK-ARM
3 
test1(void)4 void test1(void) {
5   extern void test1_helper(void (^)(int));
6 
7   // CHECK-LABEL:     define{{.*}} void @test1() {{.*}} personality ptr @__gcc_personality_v0
8   // CHECK-ARM-LABEL: define{{.*}} arm_aapcscc void @test1() {{.*}} personality ptr @__gcc_personality_sj0
9 
10   __block int x = 10;
11 
12   // CHECK:     invoke void @test1_helper(
13   // CHECK-ARM: invoke arm_aapcscc void @test1_helper(
14   test1_helper(^(int v) { x = v; });
15 
16   // CHECK:          landingpad { ptr, i32 }
17   // CHECK-NEXT:       cleanup
18   // CHECK-ARM:      landingpad { ptr, i32 }
19   // CHECK-ARM-NEXT:   cleanup
20 }
21 
22 void test2_helper();
test2(void)23 void test2(void) {
24   __block int x = 10;
25   ^{ (void)x; };
26   test2_helper(5, 6, 7);
27 }
test2_helper(int x,int y)28 void test2_helper(int x, int y) {
29 }
30 // CHECK: invoke void @test2_helper(i32 noundef 5, i32 noundef 6)
31