StmtPrinter: factor out arg printing code to PrintCallArgs
[clang.git] / test / CodeGenObjC / blocks-2.m
blob8754ff7c3f4a1fa9dad859903b848dcb3410c487
1 // We run this twice, once as Objective-C and once as Objective-C++.
2 // RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 | FileCheck %s
3 // RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -x objective-c++ | FileCheck %s
6 // CHECK: define i8* @{{.*}}test0
7 // CHECK: define internal void @__test0_block_invoke_0(
8 // CHECK:      call i8* @objc_assign_strongCast(
9 // CHECK-NEXT: ret void
10 id test0(id x) {
11   __block id result;
12   ^{ result = x; }();
13   return result;
16 // <rdar://problem/8224178>: cleanup __block variables on EH path
17 // CHECK: define void @{{.*}}test1
18 void test1() {
19   extern void test1_help(void (^x)(void));
21   // CHECK:      [[N:%.*]] = alloca [[N_T:%.*]], align 8
22   // CHECK:      [[T0:%.*]] = getelementptr inbounds [[N_T]]* [[N]], i32 0, i32 4
23   // CHECK-NEXT: store double 1.000000e+{{0?}}01, double* [[T0]], align 8
24   __block double n = 10;
26   // CHECK:      invoke void @{{.*}}test1_help
27   test1_help(^{ n = 20; });
29   // CHECK:      [[FORWARDING:%.*]] = getelementptr inbounds [[N_T]]* [[N]], i32 0, i32 1
30   // CHECK-NEXT: [[T0:%.*]] = load [[N_T]]** [[FORWARDING]]
31   // CHECK-NEXT: [[T1:%.*]] = bitcast [[N_T]]* [[T0]] to i8*
32   // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8)
33   // CHECK-NEXT: ret void
35   // CHECK:      call i8* @llvm.eh.exception()
36   // CHECK:      [[FORWARDING:%.*]] = getelementptr inbounds [[N_T]]* [[N]], i32 0, i32 1
37   // CHECK-NEXT: [[T0:%.*]] = load [[N_T]]** [[FORWARDING]]
38   // CHECK-NEXT: [[T1:%.*]] = bitcast [[N_T]]* [[T0]] to i8*
39   // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8)
40   // CHECK:      call void @_Unwind_Resume_or_Rethrow(