John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fobjc-nonfragile-abi -fobjc-arc -fblocks -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s | FileCheck %s |
| 2 | |
| 3 | typedef __strong id strong_id; |
| 4 | typedef __weak id weak_id; |
| 5 | |
| 6 | // CHECK: define void @_Z8test_newP11objc_object |
| 7 | void test_new(id invalue) { |
| 8 | // CHECK: alloca i8* |
| 9 | // CHECK-NEXT: call i8* @objc_retain |
| 10 | |
| 11 | // CHECK: call noalias i8* @_Znwm |
| 12 | // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}} |
| 13 | // CHECK-NEXT: store i8* null, i8** |
| 14 | new strong_id; |
| 15 | // CHECK: call noalias i8* @_Znwm |
| 16 | // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}} |
| 17 | // CHECK-NEXT: store i8* null, i8** |
| 18 | new weak_id; |
| 19 | |
| 20 | // CHECK: call noalias i8* @_Znwm |
| 21 | // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}} |
| 22 | // CHECK-NEXT: store i8* null, i8** |
| 23 | new __strong id; |
| 24 | // CHECK: call noalias i8* @_Znwm |
| 25 | // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}} |
| 26 | // CHECK-NEXT: store i8* null, i8** |
| 27 | new __weak id; |
| 28 | |
| 29 | // CHECK: call noalias i8* @_Znwm |
| 30 | // CHECK: call i8* @objc_retain |
| 31 | // CHECK: store i8* |
| 32 | new __strong id(invalue); |
| 33 | |
| 34 | // CHECK: call noalias i8* @_Znwm |
| 35 | // CHECK: call i8* @objc_initWeak |
| 36 | new __weak id(invalue); |
| 37 | |
| 38 | // CHECK: call void @objc_release |
| 39 | // CHECK: ret void |
| 40 | } |
| 41 | |
| 42 | // CHECK: define void @_Z14test_array_new |
| 43 | void test_array_new() { |
| 44 | // CHECK: call noalias i8* @_Znam |
| 45 | // CHECK: store i64 17, i64* |
| 46 | // CHECK: call void @llvm.memset.p0i8.i64 |
| 47 | new strong_id[17]; |
| 48 | |
| 49 | // CHECK: call noalias i8* @_Znam |
| 50 | // CHECK: store i64 17, i64* |
| 51 | // CHECK: call void @llvm.memset.p0i8.i64 |
| 52 | new weak_id[17]; |
| 53 | // CHECK: ret void |
| 54 | } |
| 55 | |
| 56 | // CHECK: define void @_Z11test_deletePU8__strongP11objc_objectPU6__weakS0_ |
| 57 | void test_delete(__strong id *sptr, __weak id *wptr) { |
| 58 | // CHECK: br i1 |
| 59 | // CHECK: load i8** |
| 60 | // CHECK-NEXT: call void @objc_release |
| 61 | // CHECK: call void @_ZdlPv |
| 62 | delete sptr; |
| 63 | |
| 64 | // CHECK: call void @objc_destroyWeak |
| 65 | // CHECK: call void @_ZdlPv |
| 66 | delete wptr; |
| 67 | |
| 68 | // CHECK: ret void |
| 69 | } |
| 70 | |
| 71 | // CHECK: define void @_Z17test_array_deletePU8__strongP11objc_objectPU6__weakS0_ |
| 72 | void test_array_delete(__strong id *sptr, __weak id *wptr) { |
| 73 | // CHECK: load i64* |
| 74 | // CHECK: {{icmp ne i64.*, 0}} |
| 75 | // CHECK: call void @objc_release |
| 76 | // CHECK: br label |
| 77 | // CHECK: call void @_ZdaPv |
| 78 | delete [] sptr; |
| 79 | |
| 80 | // CHECK: load i64* |
| 81 | // CHECK: {{icmp ne i64.*, 0}} |
| 82 | // CHECK: call void @objc_destroyWeak |
| 83 | // CHECK: br label |
| 84 | // CHECK: call void @_ZdaPv |
| 85 | delete [] wptr; |
| 86 | } |