1 // 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 7 void test0_helper(void); 8 void test0(void) { 9 @try { 10 test0_helper(); 11 } @catch (Ety *e) { 12 } 13 } 14 // CHECK: define void @test0() 15 // 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* 20 // CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]]) nounwind 21 // CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[ETY]]* 22 // CHECK-NEXT: store [[ETY]]* [[T4]], [[ETY]]** [[E]] 23 // CHECK-NEXT: [[T0:%.*]] = load [[ETY]]** [[E]] 24 // CHECK-NEXT: [[T1:%.*]] = bitcast [[ETY]]* [[T0]] to i8* 25 // CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind 26 // CHECK-NEXT: call void @objc_end_catch() nounwind 27 28 void test1_helper(void); 29 void test1(void) { 30 @try { 31 test1_helper(); 32 } @catch (__weak Ety *e) { 33 } 34 } 35 // CHECK: define void @test1() 36 // CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8 37 // CHECK-NEXT: invoke void @test1_helper() 38 // CHECK: [[T0:%.*]] = call i8* @objc_begin_catch( 39 // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]* 40 // CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]** [[E]] to i8** 41 // CHECK-NEXT: [[T3:%.*]] = bitcast [[ETY]]* [[T1]] to i8* 42 // CHECK-NEXT: call i8* @objc_initWeak(i8** [[T2]], i8* [[T3]]) nounwind 43 // CHECK-NEXT: [[T0:%.*]] = bitcast [[ETY]]** [[E]] to i8** 44 // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) nounwind 45 // CHECK-NEXT: call void @objc_end_catch() nounwind 46