summaryrefslogtreecommitdiff
path: root/test/ARCMT/Common.h
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-06-01 00:10:47 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-06-01 00:10:47 +0000
commit684190b8dbe5258f4708ffbd816b8c5ee5b3502d (patch)
tree4f66dd6f59ed700f2a675fa9f4f4645e2d8b234c /test/ARCMT/Common.h
parent1dfc4ba88714d8ac9a85dba051cf94e57f7b3e04 (diff)
downloadclang-684190b8dbe5258f4708ffbd816b8c5ee5b3502d.tar.gz
[arcmt] Use CFBridgingRetain/CFBridgingRelease instead of __bridge_retained/__bridge_transfer
when migrating. rdar://11569198 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157785 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/ARCMT/Common.h')
-rw-r--r--test/ARCMT/Common.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/test/ARCMT/Common.h b/test/ARCMT/Common.h
index 708e407c92..ed48949702 100644
--- a/test/ARCMT/Common.h
+++ b/test/ARCMT/Common.h
@@ -6,6 +6,7 @@
#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
#define CF_CONSUMED __attribute__((cf_consumed))
+#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
#define NS_INLINE static __inline__ __attribute__((always_inline))
#define nil ((void*) 0)
@@ -21,7 +22,7 @@ typedef struct _NSZone NSZone;
typedef const void * CFTypeRef;
CFTypeRef CFRetain(CFTypeRef cf);
-id CFBridgingRelease(CFTypeRef CF_CONSUMED X);
+CFTypeRef CFMakeCollectable(CFTypeRef cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
@@ -79,3 +80,25 @@ typedef id xpc_object_t;
void _dispatch_object_validate(dispatch_object_t object);
void _xpc_object_validate(xpc_object_t object);
+
+#if __has_feature(objc_arc)
+
+NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
+ return (__bridge_retained CFTypeRef)X;
+}
+
+NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
+ return (__bridge_transfer id)X;
+}
+
+#else
+
+NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
+ return X ? CFRetain((CFTypeRef)X) : NULL;
+}
+
+NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
+ return [(id)CFMakeCollectable(X) autorelease];
+}
+
+#endif