• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: ret void
35}
36
37// CHECK-LABEL: define void @bridge_from_cf
38void bridge_from_cf(int *i) {
39  // CHECK: store i32 7
40  *i = 7;
41  // CHECK: call i8* @CFCreateSomething()
42  id obj1 = (__bridge id)CFCreateSomething();
43  // CHECK: objc_retainAutoreleasedReturnValue
44  // CHECK: store i32 11
45  *i = 11;
46  // CHECK: call i8* @CFCreateSomething()
47  // CHECK-NOT: release
48  // CHECK: store i32 13
49  (void)(__bridge id)CFCreateSomething(), *i = 13;
50  // CHECK: store i32 17
51  *i = 17;
52  // CHECK: call void @objc_release
53  // CHECK-NEXT: ret void
54}
55
56// CHECK-LABEL: define void @bridge_retained_of_cf
57void bridge_retained_of_cf(int *i) {
58  *i = 7;
59  // CHECK: call i8* @CreateSomething()
60  CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething();
61  // CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue
62  // CHECK: store i32 11
63  *i = 11;
64  // CHECK: call i8* @CreateSomething()
65  (__bridge_retained CFTypeRef)CreateSomething(), *i = 13;
66  // CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue
67  // CHECK: store i32 13
68  // CHECK: store i32 17
69  *i = 17;
70  // CHECK-NEXT: ret void
71}
72
73// CHECK-LABEL: define void @bridge_of_cf
74void bridge_of_cf(int *i) {
75  // CHECK: store i32 7
76  *i = 7;
77  // CHECK: call i8* @CreateSomething()
78  CFTypeRef cf1 = (__bridge CFTypeRef)CreateSomething();
79  // CHECK-NOT: retain
80  // CHECK: store i32 11
81  *i = 11;
82  // CHECK: call i8* @CreateSomething
83  (__bridge CFTypeRef)CreateSomething(), *i = 13;
84  // CHECK: store i32 13
85  // CHECK-NOT: release
86  // CHECK: store i32 17
87  *i = 17;
88  // CHECK-NEXT: ret void
89}
90
91