diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-06-01 00:10:47 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-06-01 00:10:47 +0000 |
commit | 684190b8dbe5258f4708ffbd816b8c5ee5b3502d (patch) | |
tree | 4f66dd6f59ed700f2a675fa9f4f4645e2d8b234c /test/ARCMT | |
parent | 1dfc4ba88714d8ac9a85dba051cf94e57f7b3e04 (diff) |
[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')
-rw-r--r-- | test/ARCMT/Common.h | 25 | ||||
-rw-r--r-- | test/ARCMT/autoreleases.m.result | 2 | ||||
-rw-r--r-- | test/ARCMT/nonobjc-to-objc-cast.m.result | 30 |
3 files changed, 40 insertions, 17 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 diff --git a/test/ARCMT/autoreleases.m.result b/test/ARCMT/autoreleases.m.result index 93ec9717dd..6593fc9199 100644 --- a/test/ARCMT/autoreleases.m.result +++ b/test/ARCMT/autoreleases.m.result @@ -35,7 +35,7 @@ _prop = newVal; } -(void) setProp2:(CFTypeRef) newVal { - _prop = (__bridge_transfer id)CFRetain(newVal); + _prop = (id)CFBridgingRelease(CFRetain(newVal)); } -(id) xpc_prop { diff --git a/test/ARCMT/nonobjc-to-objc-cast.m.result b/test/ARCMT/nonobjc-to-objc-cast.m.result index b50a948e27..0a3b2bb526 100644 --- a/test/ARCMT/nonobjc-to-objc-cast.m.result +++ b/test/ARCMT/nonobjc-to-objc-cast.m.result @@ -28,9 +28,9 @@ void f(BOOL b, id p) { str = (NSString *)p; // no change. CFUUIDRef _uuid; - NSString *_uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid); - _uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid); - _uuidString = (__bridge_transfer NSString *)(CFRetain(_uuid)); + NSString *_uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid)); + _uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid)); + _uuidString = CFBridgingRelease(CFRetain(_uuid)); } @implementation NSString (StrExt) @@ -47,16 +47,16 @@ void f2(NSString *s) { CFStringRef ref = (__bridge CFStringRef)([s string]); ref = (__bridge CFStringRef)[s string]; ref = (__bridge CFStringRef)(s.string); - ref = (__bridge_retained CFStringRef)([NSString new]); - ref = (__bridge_retained CFStringRef)([s newString]); - ref = (__bridge_retained CFStringRef)[NSString new]; - ref = (__bridge_retained CFStringRef)([[NSString alloc] init]); - ref = (__bridge_retained CFStringRef)([s string]); - ref = (__bridge_retained CFStringRef)[s string]; - ref = (__bridge_retained CFTypeRef)([s string]); - ref = (__bridge_retained CFTypeRef)(s); - ref = (__bridge_retained CFStringRef)(s); - - consumeParam((__bridge_retained CFStringRef)s); - consumeParam((__bridge_retained CFStringRef)(s)); + ref = CFBridgingRetain([NSString new]); + ref = CFBridgingRetain([s newString]); + ref = (CFStringRef)CFBridgingRetain([NSString new]); + ref = CFBridgingRetain([[NSString alloc] init]); + ref = CFBridgingRetain([s string]); + ref = (CFStringRef)CFBridgingRetain([s string]); + ref = CFBridgingRetain([s string]); + ref = CFBridgingRetain(s); + ref = CFBridgingRetain(s); + + consumeParam((CFStringRef)CFBridgingRetain(s)); + consumeParam(CFBridgingRetain(s)); } |