1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s 2 3typedef const void *CFTypeRef; 4typedef const struct __CFString *CFStringRef; 5 6@interface NSString 7@end 8 9CFTypeRef CFCreateSomething(void); 10CFStringRef CFCreateString(void); 11CFTypeRef CFGetSomething(void); 12CFStringRef CFGetString(void); 13 14id CreateSomething(void); 15NSString *CreateNSString(void); 16 17// CHECK-LABEL: define void @bridge_transfer_from_cf 18void bridge_transfer_from_cf(int *i) { 19 // CHECK: store i32 7 20 *i = 7; 21 // CHECK: call i8* @CFCreateSomething() 22 id obj1 = (__bridge_transfer id)CFCreateSomething(); 23 // CHECK-NOT: retain 24 // CHECK: store i32 11 25 *i = 11; 26 // CHECK: call i8* @CFCreateSomething() 27 // CHECK-NOT: retain 28 // CHECK: store i32 13 29 (void)(__bridge_transfer id)CFCreateSomething(), *i = 13; 30 // CHECK: call void @objc_release 31 // CHECK: store i32 17 32 *i = 17; 33 // CHECK: call void @objc_release 34 // CHECK-NEXT: bitcast 35 // CHECK-NEXT: call void @llvm.lifetime.end 36 // CHECK-NEXT: ret void 37} 38 39// CHECK-LABEL: define void @bridge_from_cf 40void bridge_from_cf(int *i) { 41 // CHECK: store i32 7 42 *i = 7; 43 // CHECK: call i8* @CFCreateSomething() 44 id obj1 = (__bridge id)CFCreateSomething(); 45 // CHECK: objc_retainAutoreleasedReturnValue 46 // CHECK: store i32 11 47 *i = 11; 48 // CHECK: call i8* @CFCreateSomething() 49 // CHECK-NOT: release 50 // CHECK: store i32 13 51 (void)(__bridge id)CFCreateSomething(), *i = 13; 52 // CHECK: store i32 17 53 *i = 17; 54 // CHECK: call void @objc_release 55 // CHECK-NEXT: bitcast 56 // CHECK-NEXT: call void @llvm.lifetime.end 57 // CHECK-NEXT: ret void 58} 59 60// CHECK-LABEL: define void @bridge_retained_of_cf 61void bridge_retained_of_cf(int *i) { 62 *i = 7; 63 // CHECK: call i8* @CreateSomething() 64 CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); 65 // CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue 66 // CHECK: store i32 11 67 *i = 11; 68 // CHECK: call i8* @CreateSomething() 69 (__bridge_retained CFTypeRef)CreateSomething(), *i = 13; 70 // CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue 71 // CHECK: store i32 13 72 // CHECK: store i32 17 73 *i = 17; 74 // CHECK-NEXT: bitcast 75 // CHECK-NEXT: call void @llvm.lifetime.end 76 // CHECK-NEXT: ret void 77} 78 79// CHECK-LABEL: define void @bridge_of_cf 80void bridge_of_cf(int *i) { 81 // CHECK: store i32 7 82 *i = 7; 83 // CHECK: call void @llvm.lifetime.start 84 // CHECK-NEXT: call i8* @CreateSomething() 85 CFTypeRef cf1 = (__bridge CFTypeRef)CreateSomething(); 86 // CHECK-NOT: retain 87 // CHECK: store i32 11 88 *i = 11; 89 // CHECK: call i8* @CreateSomething 90 (__bridge CFTypeRef)CreateSomething(), *i = 13; 91 // CHECK: store i32 13 92 // CHECK-NOT: release 93 // CHECK: store i32 17 94 *i = 17; 95 // CHECK-NEXT: bitcast 96 // CHECK-NEXT: call void @llvm.lifetime.end 97 // CHECK-NEXT: ret void 98} 99 100