blob: dafffd81f506bedf5f388d3cf58226e2ee9de342 [file] [log] [blame]
John McCallb29b12d2012-01-17 20:16:56 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fexceptions -fobjc-exceptions -fobjc-runtime-has-weak -o - %s | FileCheck %s
2
3@class Ety;
4
5// These first two tests are all PR11732 / rdar://problem/10667070.
6
7void test0_helper(void);
8void test0(void) {
9 @try {
10 test0_helper();
11 } @catch (Ety *e) {
12 }
13}
Stephen Lin93ab6bf2013-08-15 06:47:53 +000014// CHECK-LABEL: define void @test0()
John McCallb29b12d2012-01-17 20:16:56 +000015// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
16// CHECK-NEXT: invoke void @test0_helper()
17// CHECK: [[T0:%.*]] = call i8* @objc_begin_catch(
18// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
19// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
Bill Wendling4e1125f2013-02-22 09:10:20 +000020// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]]) [[NUW:#[0-9]+]]
John McCallb29b12d2012-01-17 20:16:56 +000021// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[ETY]]*
22// CHECK-NEXT: store [[ETY]]* [[T4]], [[ETY]]** [[E]]
John McCall015f33b2012-10-17 02:28:37 +000023// CHECK-NEXT: [[T0:%.*]] = bitcast [[ETY]]** [[E]] to i8**
Bill Wendling4e1125f2013-02-22 09:10:20 +000024// CHECK-NEXT: call void @objc_storeStrong(i8** [[T0]], i8* null) [[NUW]]
25// CHECK-NEXT: call void @objc_end_catch() [[NUW]]
John McCallb29b12d2012-01-17 20:16:56 +000026
27void test1_helper(void);
28void test1(void) {
29 @try {
30 test1_helper();
31 } @catch (__weak Ety *e) {
32 }
33}
Stephen Lin93ab6bf2013-08-15 06:47:53 +000034// CHECK-LABEL: define void @test1()
John McCallb29b12d2012-01-17 20:16:56 +000035// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
36// CHECK-NEXT: invoke void @test1_helper()
37// CHECK: [[T0:%.*]] = call i8* @objc_begin_catch(
38// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
39// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]** [[E]] to i8**
40// CHECK-NEXT: [[T3:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
Bill Wendling4e1125f2013-02-22 09:10:20 +000041// CHECK-NEXT: call i8* @objc_initWeak(i8** [[T2]], i8* [[T3]]) [[NUW]]
John McCallb29b12d2012-01-17 20:16:56 +000042// CHECK-NEXT: [[T0:%.*]] = bitcast [[ETY]]** [[E]] to i8**
Bill Wendling4e1125f2013-02-22 09:10:20 +000043// CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) [[NUW]]
44// CHECK-NEXT: call void @objc_end_catch() [[NUW]]
45
46// CHECK: attributes [[NUW]] = { nounwind }