1 // RUN: %clang_cc1 -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 ptr @CFCreateSomething()
22 id obj1 = (__bridge_transfer id)CFCreateSomething();
24 // CHECK: store i32 11
26 // CHECK: call ptr @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: call void @llvm.lifetime.end
35 // CHECK-NEXT: ret void
38 // CHECK-LABEL: define{{.*}} void @bridge_from_cf
39 void bridge_from_cf(int *i) {
42 // CHECK: call ptr @CFCreateSomething() [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
43 id obj1 = (__bridge id)CFCreateSomething();
44 // CHECK: store i32 11
46 // CHECK: call ptr @CFCreateSomething()
48 // CHECK: store i32 13
49 (void)(__bridge id)CFCreateSomething(), *i = 13;
50 // CHECK: store i32 17
52 // CHECK: call void @llvm.objc.release
53 // CHECK-NEXT: call void @llvm.lifetime.end
54 // CHECK-NEXT: ret void
57 // CHECK-LABEL: define{{.*}} void @bridge_retained_of_cf
58 void bridge_retained_of_cf(int *i) {
60 // CHECK: call ptr @CreateSomething() [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
61 CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething();
62 // CHECK: store i32 11
64 // CHECK: call ptr @CreateSomething() [ "clang.arc.attachedcall"(ptr @llvm.objc.retainAutoreleasedReturnValue) ]
65 (__bridge_retained CFTypeRef)CreateSomething(), *i = 13;
66 // CHECK: store i32 13
67 // CHECK: store i32 17
69 // CHECK-NEXT: call void @llvm.lifetime.end
70 // CHECK-NEXT: ret void
73 // CHECK-LABEL: define{{.*}} void @bridge_of_cf
74 void bridge_of_cf(int *i) {
77 // CHECK: call void @llvm.lifetime.start
78 // CHECK-NEXT: call ptr @CreateSomething()
79 CFTypeRef cf1 = (__bridge CFTypeRef)CreateSomething();
81 // CHECK: store i32 11
83 // CHECK: call ptr @CreateSomething
84 (__bridge CFTypeRef)CreateSomething(), *i = 13;
85 // CHECK: store i32 13
87 // CHECK: store i32 17
89 // CHECK-NEXT: call void @llvm.lifetime.end
90 // CHECK-NEXT: ret void
93 // CHECK-LABEL: define{{.*}} ptr @bridge_of_paren_expr()
94 CFStringRef bridge_of_paren_expr(void) {
95 // CHECK-NOT: "@llvm.objc"
96 CFStringRef r = (__bridge CFStringRef)(CreateNSString());
97 r = (__bridge CFStringRef)((NSString *)(CreateNSString()));