1 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -O2 -disable-llvm-passes -o - %s | FileCheck %s
3 typedef const void *CFTypeRef;
4 typedef const struct __CFString *CFStringRef;
9 CFTypeRef CFCreateSomething(void);
10 CFStringRef CFCreateString(void);
11 CFTypeRef CFGetSomething(void);
12 CFStringRef CFGetString(void);
14 id CreateSomething(void);
15 NSString *CreateNSString(void);
17 // CHECK-LABEL: define{{.*}} void @bridge_transfer_from_cf
18 void bridge_transfer_from_cf(int *i) {
21 // CHECK: call i8* @CFCreateSomething()
22 id obj1 = (__bridge_transfer id)CFCreateSomething();
24 // CHECK: store i32 11
26 // CHECK: call i8* @CFCreateSomething()
28 // CHECK: store i32 13
29 (void)(__bridge_transfer id)CFCreateSomething(), *i = 13;
30 // CHECK: call void @llvm.objc.release
31 // CHECK: store i32 17
33 // CHECK: call void @llvm.objc.release
34 // CHECK-NEXT: bitcast
35 // CHECK-NEXT: call void @llvm.lifetime.end
36 // CHECK-NEXT: ret void
39 // CHECK-LABEL: define{{.*}} void @bridge_from_cf
40 void bridge_from_cf(int *i) {
43 // CHECK: call i8* @CFCreateSomething() [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
44 id obj1 = (__bridge id)CFCreateSomething();
45 // CHECK: store i32 11
47 // CHECK: call i8* @CFCreateSomething()
49 // CHECK: store i32 13
50 (void)(__bridge id)CFCreateSomething(), *i = 13;
51 // CHECK: store i32 17
53 // CHECK: call void @llvm.objc.release
54 // CHECK-NEXT: bitcast
55 // CHECK-NEXT: call void @llvm.lifetime.end
56 // CHECK-NEXT: ret void
59 // CHECK-LABEL: define{{.*}} void @bridge_retained_of_cf
60 void bridge_retained_of_cf(int *i) {
62 // CHECK: call i8* @CreateSomething() [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
63 CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething();
64 // CHECK: store i32 11
66 // CHECK: call i8* @CreateSomething() [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
67 (__bridge_retained CFTypeRef)CreateSomething(), *i = 13;
68 // CHECK: store i32 13
69 // CHECK: store i32 17
71 // CHECK-NEXT: bitcast
72 // CHECK-NEXT: call void @llvm.lifetime.end
73 // CHECK-NEXT: ret void
76 // CHECK-LABEL: define{{.*}} void @bridge_of_cf
77 void bridge_of_cf(int *i) {
80 // CHECK: call void @llvm.lifetime.start
81 // CHECK-NEXT: call i8* @CreateSomething()
82 CFTypeRef cf1 = (__bridge CFTypeRef)CreateSomething();
84 // CHECK: store i32 11
86 // CHECK: call i8* @CreateSomething
87 (__bridge CFTypeRef)CreateSomething(), *i = 13;
88 // CHECK: store i32 13
90 // CHECK: store i32 17
92 // CHECK-NEXT: bitcast
93 // CHECK-NEXT: call void @llvm.lifetime.end
94 // CHECK-NEXT: ret void
97 // CHECK-LABEL: define{{.*}} %struct.__CFString* @bridge_of_paren_expr()
98 CFStringRef bridge_of_paren_expr(void) {
99 // CHECK-NOT: "@llvm.objc"
100 CFStringRef r = (__bridge CFStringRef)(CreateNSString());
101 r = (__bridge CFStringRef)((NSString *)(CreateNSString()));