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