#ifndef CF_IMPLICIT_BRIDGING_ENABLED
#if __has_feature(arc_cf_code_audited)
#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin")
#else
#define CF_IMPLICIT_BRIDGING_ENABLED
#endif
#endif
#ifndef CF_IMPLICIT_BRIDGING_DISABLED
#if __has_feature(arc_cf_code_audited)
#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end")
#else
#define CF_IMPLICIT_BRIDGING_DISABLED
#endif
#endif
#if __has_feature(attribute_ns_returns_retained)
#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
#endif
#if __has_feature(attribute_cf_returns_retained)
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
#endif
#if __has_feature(attribute_ns_returns_not_retained)
#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
#endif
#if __has_feature(attribute_cf_returns_not_retained)
#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
#endif
#if __has_feature(attribute_ns_consumes_self)
#define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
#endif
#if __has_feature(attribute_ns_consumed)
#define NS_CONSUMED __attribute__((ns_consumed))
#endif
#if __has_feature(attribute_cf_consumed)
#define CF_CONSUMED __attribute__((cf_consumed))
#endif
#if __has_attribute(ns_returns_autoreleased)
#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased))
#endif
typedef unsigned int __darwin_natural_t;
typedef unsigned long uintptr_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef unsigned int UInt32;
typedef signed long CFIndex;
typedef CFIndex CFByteOrder;
typedef struct {
CFIndex location;
CFIndex length;
} CFRange;
static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) {
CFRange range;
range.location = loc;
range.length = len;
return range;
}
typedef const void * CFTypeRef;
typedef const struct __CFString * CFStringRef;
typedef const struct __CFAllocator * CFAllocatorRef;
extern const CFAllocatorRef kCFAllocatorDefault;
extern CFTypeRef CFRetain(CFTypeRef cf);
extern void CFRelease(CFTypeRef cf);
extern CFTypeRef CFAutorelease(CFTypeRef cf);
extern CFTypeRef CFMakeCollectable(CFTypeRef cf);
typedef struct {
}
CFArrayCallBacks;
extern const CFArrayCallBacks kCFTypeArrayCallBacks;
typedef const struct __CFArray * CFArrayRef;
typedef struct __CFArray * CFMutableArrayRef;
extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks);
extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value);
typedef struct {
}
CFDictionaryKeyCallBacks;
extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
typedef struct {
}
CFDictionaryValueCallBacks;
extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
typedef const struct __CFDictionary * CFDictionaryRef;
typedef struct __CFDictionary * CFMutableDictionaryRef;
extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
typedef UInt32 CFStringEncoding;
enum {
kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 };
extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding);
typedef double CFTimeInterval;
typedef CFTimeInterval CFAbsoluteTime;
extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
typedef const struct __CFDate * CFDateRef;
extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at);
extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate);
typedef __darwin_natural_t natural_t;
typedef natural_t mach_port_name_t;
typedef mach_port_name_t mach_port_t;
typedef int kern_return_t;
typedef kern_return_t mach_error_t;
enum {
kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 };
typedef CFIndex CFNumberType;
typedef const struct __CFNumber * CFNumberRef;
extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
typedef const struct __CFAttributedString *CFAttributedStringRef;
typedef struct __CFAttributedString *CFMutableAttributedStringRef;
extern CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes) ;
extern CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr) ;
extern void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value) ;
typedef signed char BOOL;
typedef unsigned long NSUInteger;
@class NSString, Protocol;
extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (id)retain;
- (oneway void)release;
- (id)autorelease;
- (NSString *)description;
- (id)init;
@end
@protocol NSCopying
- (id)copyWithZone:(NSZone *)zone;
@end
@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
@end
@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
@end
@interface NSObject <NSObject> {}
+ (id)allocWithZone:(NSZone *)zone;
+ (id)alloc;
+ (id)new;
- (void)dealloc;
@end
@interface NSObject (NSCoderMethods)
- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
@end
extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
typedef struct {
}
NSFastEnumerationState;
@protocol NSFastEnumeration
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
@end
@class NSString, NSDictionary;
@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
@end
@interface NSNumber : NSValue
- (char)charValue;
- (id)initWithInt:(int)value;
+ (NSNumber *)numberWithInt:(int)value;
@end
@class NSString;
@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
- (NSUInteger)count;
- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt;
+ (id)arrayWithObject:(id)anObject;
+ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
+ (id)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
- (id)initWithArray:(NSArray *)array;
@end @interface NSArray (NSArrayCreation) + (id)array;
@end @interface NSAutoreleasePool : NSObject {
}
- (void)drain;
@end extern NSString * const NSBundleDidLoadNotification;
typedef double NSTimeInterval;
@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
@end typedef unsigned short unichar;
@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
- (NSUInteger)length;
- (NSString *)stringByAppendingString:(NSString *)aString;
- ( const char *)UTF8String;
- (id)initWithUTF8String:(const char *)nullTerminatedCString;
+ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
@end @class NSString, NSURL, NSError;
@interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
- (NSUInteger)count;
+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
@end
@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
- (void)setObject:(id)anObject forKey:(id)aKey;
@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems;
@end typedef double CGFloat;
struct CGSize {
};
typedef struct CGSize CGSize;
struct CGRect {
};
typedef struct CGRect CGRect;
typedef mach_port_t io_object_t;
typedef char io_name_t[128];
typedef io_object_t io_iterator_t;
typedef io_object_t io_service_t;
typedef struct IONotificationPort * IONotificationPortRef;
typedef void (*IOServiceMatchingCallback)( void * refcon, io_iterator_t iterator );
io_service_t IOServiceGetMatchingService( mach_port_t mainPort, CFDictionaryRef matching );
kern_return_t IOServiceGetMatchingServices( mach_port_t mainPort, CFDictionaryRef matching, io_iterator_t * existing );
kern_return_t IOServiceAddNotification( mach_port_t mainPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated)); kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification );
CFMutableDictionaryRef IOServiceMatching( const char * name );
CFMutableDictionaryRef IOServiceNameMatching( const char * name );
CFMutableDictionaryRef IOBSDNameMatching( mach_port_t mainPort, uint32_t options, const char * bsdName );
CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t mainPort, uint32_t options, const char * path );
CFMutableDictionaryRef IORegistryEntryIDMatching( uint64_t entryID );
typedef struct __DASession * DASessionRef;
extern DASessionRef DASessionCreate( CFAllocatorRef allocator );
typedef struct __DADisk * DADiskRef;
extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name );
extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media );
extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk );
extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk );
@interface NSTask : NSObject - (id)init;
@end typedef struct CGColorSpace *CGColorSpaceRef;
typedef struct CGImage *CGImageRef;
typedef struct CGLayer *CGLayerRef;
@interface NSResponder : NSObject <NSCoding> {
}
@end @protocol NSAnimatablePropertyContainer - (id)animator;
@end extern NSString *NSAnimationTriggerOrderIn ;
@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
}
@end @protocol NSValidatedUserInterfaceItem - (SEL)action;
@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
@end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
@class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
@interface NSApplication : NSResponder <NSUserInterfaceValidations> {
}
- (void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)docWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo;
@end enum {
NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 };
typedef NSUInteger NSApplicationTerminateReply;
@protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView;
@interface NSCell : NSObject <NSCopying, NSCoding> {
}
@end
typedef struct {
}
CVTimeStamp;
@interface CIImage : NSObject <NSCoding, NSCopying> {
}
typedef int CIFormat;
@end enum {
kDAReturnSuccess = 0, kDAReturnError = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01, kDAReturnBusy = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02, kDAReturnBadArgument = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03, kDAReturnExclusiveAccess = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04, kDAReturnNoResources = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05, kDAReturnNotFound = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06, kDAReturnNotMounted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07, kDAReturnNotPermitted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08, kDAReturnNotPrivileged = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09, kDAReturnNotReady = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A, kDAReturnNotWritable = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B, kDAReturnUnsupported = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C };
typedef mach_error_t DAReturn;
typedef const struct __DADissenter * DADissenterRef;
extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string );
@interface CIContext: NSObject {
}
- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r;
- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs;
- (CGLayerRef)createCGLayerWithSize:(CGSize)size info:(CFDictionaryRef)d;
@end extern NSString* const QCRendererEventKey;
@protocol QCCompositionRenderer - (NSDictionary*) attributes;
@end @interface QCRenderer : NSObject <QCCompositionRenderer> {
}
- (id) createSnapshotImageOfType:(NSString*)type;
@end extern NSString* const QCViewDidStartRenderingNotification;
@interface QCView : NSView <QCCompositionRenderer> {
}
- (id) createSnapshotImageOfType:(NSString*)type;
@end enum {
ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, };
@class ICDevice;
@protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device;
@end extern NSString *const ICScannerStatusWarmingUp;
@class ICScannerDevice;
@protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner;
@end
typedef long unsigned int __darwin_size_t;
typedef __darwin_size_t size_t;
typedef unsigned long CFTypeID;
struct CGPoint {
CGFloat x;
CGFloat y;
};
typedef struct CGPoint CGPoint;
typedef struct CGGradient *CGGradientRef;
typedef uint32_t CGGradientDrawingOptions;
extern CFTypeID CGGradientGetTypeID(void);
extern CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef
space, const CGFloat components[], const CGFloat locations[], size_t count);
extern CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space,
CFArrayRef colors, const CGFloat locations[]);
extern CGGradientRef CGGradientRetain(CGGradientRef gradient);
extern void CGGradientRelease(CGGradientRef gradient);
typedef struct CGContext *CGContextRef;
extern void CGContextDrawLinearGradient(CGContextRef context,
CGGradientRef gradient, CGPoint startPoint, CGPoint endPoint,
CGGradientDrawingOptions options);
extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
@interface NSMutableArray : NSObject
- (void)addObject:(id)object;
+ (id)array;
@end
id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained));
typedef const struct __CFUUID * CFUUIDRef;
extern
void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
CFAbsoluteTime f1(void) {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t);
CFRetain(date);
CFRelease(date);
CFDateGetAbsoluteTime(date); CFRelease(date);
t = CFDateGetAbsoluteTime(date); return t;
}
CFAbsoluteTime f2(void) {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t);
[((NSDate*) date) retain];
CFRelease(date);
CFDateGetAbsoluteTime(date); [((NSDate*) date) release];
t = CFDateGetAbsoluteTime(date); return t;
}
NSDate* global_x;
CFAbsoluteTime f3(void) {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t);
[((NSDate*) date) retain];
CFRelease(date);
CFDateGetAbsoluteTime(date); global_x = (NSDate*) date;
[((NSDate*) date) release];
t = CFDateGetAbsoluteTime(date); return t;
}
CFAbsoluteTime f5(int x) {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t);
if (x)
CFRelease(date);
return t;
}
CFDateRef f6(int x) {
CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); CFRetain(date);
return date;
}
CFDateRef f7(void) {
CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); CFRetain(date);
date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); return date;
}
CFDateRef MyDateCreate(void);
CFDateRef f8(void) {
CFDateRef date = MyDateCreate(); CFRetain(date);
return date;
}
__attribute__((cf_returns_retained)) CFDateRef f9(void) {
CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); int *p = 0;
if (!date) *p = 1; return date;
}
void f10(io_service_t media, DADiskRef d, CFStringRef s) {
DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, 0, "hello"); if (disk) NSLog(@"ok");
disk = DADiskCreateFromIOMedia(kCFAllocatorDefault, 0, media); if (disk) NSLog(@"ok");
CFDictionaryRef dict = DADiskCopyDescription(d); if (dict) NSLog(@"ok");
disk = DADiskCopyWholeDisk(d); if (disk) NSLog(@"ok");
DADissenterRef dissenter = DADissenterCreate(kCFAllocatorDefault, kDAReturnSuccess, s);
if (dissenter) NSLog(@"ok");
DASessionRef session = DASessionCreate(kCFAllocatorDefault); if (session) NSLog(@"ok");
}
void f11(void) {
CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
CFStringRef s1 = CFStringCreateWithCString(0, "hello world",
kCFStringEncodingUTF8);
CFArrayAppendValue(A, s1);
CFRelease(s1);
s1 = (CFStringRef) CFArrayGetValueAtIndex(A, 0);
CFRelease(A);
CFRelease(s1); }
typedef CFTypeRef CREATEFUN(void);
CFTypeRef MyCreateFun(void);
void f12(void) {
CFTypeRef o = MyCreateFun(); }
void f13_autorelease(void) {
CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); [(id) A autorelease]; }
void f13_autorelease_b(void) {
CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
[(id) A autorelease];
[(id) A autorelease];
}
CFMutableArrayRef f13_autorelease_c(void) {
CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
[(id) A autorelease];
[(id) A autorelease];
return A; }
CFMutableArrayRef f13_autorelease_d(void) {
CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
[(id) A autorelease];
[(id) A autorelease];
CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); CFRelease(B); while (1) {}
}
void f14_leakimmediately(void) {
CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
void f15(void) {
CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
CFMutableArrayRef *B = &A;
CFRelease(*B); }
void f16(int x, CFTypeRef p) {
if (p)
return;
switch (x) {
case 0:
CFRelease(p);
break;
case 1:
CFRetain(p);
break;
case 2:
CFMakeCollectable(p);
break;
case 3:
CFAutorelease(p);
break;
default:
break;
}
}
void f17(int x, CFTypeRef p) {
switch (x) {
case 0:
CFRelease(p);
if (!p)
CFRelease(0); break;
case 1:
CFRetain(p);
if (!p)
CFRetain(0); break;
case 2:
CFMakeCollectable(p);
if (!p)
CFMakeCollectable(0); break;
case 3:
CFAutorelease(p);
if (!p)
CFAutorelease(0); break;
default:
break;
}
}
@interface SelfIvarTest : NSObject {
id myObj;
}
- (void)test_self_tracking;
@end
@implementation SelfIvarTest
- (void)test_self_tracking {
myObj = (id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
@end
@interface TestReturnNotOwnedWhenExpectedOwned
- (NSString*)newString;
@end
@implementation TestReturnNotOwnedWhenExpectedOwned
- (NSString*)newString {
NSString *s = [NSString stringWithUTF8String:"hello"];
return s; }
@end
int isFoo(char c);
static void rdar_6659160(char *inkind, char *inname)
{
NSString *kind = [[NSString alloc] initWithUTF8String:inkind];
NSString *name = [NSString stringWithUTF8String:inname];
if(!name)
return;
const char *kindC = 0;
const char *nameC = 0;
if(kind)
kindC = [kind UTF8String];
if(name)
nameC = [name UTF8String];
if(!isFoo(kindC[0])) return;
if(!isFoo(nameC[0])) return;
[kind release];
[name release]; }
@interface PR3677: NSObject @end
@implementation PR3677
+ (id)allocWithZone:(NSZone *)inZone {
return [super allocWithZone:inZone]; }
@end
void pr3820_DeallocInsteadOfRelease(void)
{
id foo = [[NSString alloc] init]; [foo dealloc];
}
void pr3820_ReleaseAfterDealloc(void)
{
id foo = [[NSString alloc] init];
[foo dealloc];
[foo release]; }
void pr3820_DeallocAfterRelease(void)
{
NSLog(@"\n\n[%s]", __FUNCTION__);
id foo = [[NSString alloc] init];
[foo release];
[foo dealloc]; }
void rdar6704930(unsigned char *s, unsigned int length) {
NSString* name = 0;
if (s != 0) {
if (length > 0) {
while (length > 0) {
if (*s == ':') {
++s;
--length;
name = [[NSString alloc] init]; break;
}
++s;
--length;
}
if ((length == 0) && (name != 0)) {
[name release];
name = 0;
}
if (length == 0) { name = [[NSString alloc] init]; }
}
}
if (name != 0) {
[name release];
}
}
@interface rdar_6833332 : NSObject <NSApplicationDelegate> {
NSWindow *window;
}
@property (nonatomic, retain) NSWindow *window;
@end
@implementation rdar_6833332
@synthesize window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain];
[dict setObject:@"foo" forKey:@"bar"];
NSLog(@"%@", dict);
}
- (void)dealloc {
[window release];
[super dealloc];
}
- (void)radar10102244 {
NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; if (window)
NSLog(@"%@", window);
}
@end
int rdar_6257780_Case1(void) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSArray *array = [NSArray array];
[array release]; [pool drain];
return 0;
}
void rdar_10640253_autorelease_allocWithZone(void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:(NSZone*)0] init];
(void) pool;
}
void rdar_6866843(void) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];
NSArray* array = [[NSArray alloc] init];
[dictionary setObject:array forKey:@"key"];
[array release];
NSLog(@"array = %@\n", array); [dictionary release];
[pool drain];
}
typedef CFTypeRef OtherRef;
@interface RDar6877235 : NSObject {}
- (CFTypeRef)_copyCFTypeRef;
- (OtherRef)_copyOtherRef;
@end
@implementation RDar6877235
- (CFTypeRef)_copyCFTypeRef {
return [[NSString alloc] init]; }
- (OtherRef)_copyOtherRef {
return [[NSString alloc] init]; }
@end
@interface RDar6320065 : NSObject {
NSString *_foo;
}
- (id)initReturningNewClass;
- (id)_initReturningNewClassBad;
- (id)initReturningNewClassBad2;
@end
@interface RDar6320065Subclass : RDar6320065
@end
@implementation RDar6320065
- (id)initReturningNewClass {
[self release];
self = [[RDar6320065Subclass alloc] init]; return self;
}
- (id)_initReturningNewClassBad {
[self release];
[[RDar6320065Subclass alloc] init]; return self;
}
- (id)initReturningNewClassBad2 {
[self release];
self = [[RDar6320065Subclass alloc] init];
return [self autorelease]; }
@end
@implementation RDar6320065Subclass
@end
int RDar6320065_test(void) {
RDar6320065 *test = [[RDar6320065 alloc] init]; [test release];
return 0;
}
@interface RDar7129086 : NSObject {} @end
@implementation RDar7129086
- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder {
[self release]; return [NSString alloc]; }
@end
@interface RDar6859457 : NSObject {}
- (NSString*) NoCopyString;
- (NSString*) noCopyString;
@end
@implementation RDar6859457
- (NSString*) NoCopyString { return [[NSString alloc] init]; } - (NSString*) noCopyString { return [[NSString alloc] init]; } @end
void test_RDar6859457(RDar6859457 *x, void *bytes, NSUInteger dataLength) {
[x NoCopyString]; [x noCopyString]; [NSData dataWithBytesNoCopy:bytes length:dataLength]; [NSData dataWithBytesNoCopy:bytes length:dataLength freeWhenDone:1]; }
static void PR4230(void)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *object = [[[NSString alloc] init] autorelease]; return;
}
static void PR4230_new(void)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new]; NSString *object = [[[NSString alloc] init] autorelease]; return;
}
@interface TestNullIdentifier
@end
@implementation TestNullIdentifier
+ (id):(int)x, ... {
return [[NSString alloc] init]; }
@end
typedef struct s6893565* TD6893565;
@interface RDar6893565 {}
-(TD6893565)newThing;
@end
@implementation RDar6893565
-(TD6893565)newThing {
return (TD6893565) [[NSString alloc] init]; }
@end
void rdar6902710(QCView *view, QCRenderer *renderer, CIContext *context,
NSString *str, CIImage *img, CGRect rect,
CIFormat form, CGColorSpaceRef cs) {
[view createSnapshotImageOfType:str]; [renderer createSnapshotImageOfType:str]; [context createCGImage:img fromRect:rect]; [context createCGImage:img fromRect:rect format:form colorSpace:cs]; }
void rdar6945561(CIContext *context, CGSize size, CFDictionaryRef d) {
[context createCGLayerWithSize:size info:d]; }
void IOBSDNameMatching_wrapper(mach_port_t mainPort, uint32_t options, const char * bsdName) {
IOBSDNameMatching(mainPort, options, bsdName); }
void IOServiceMatching_wrapper(const char * name) {
IOServiceMatching(name); }
void IOServiceNameMatching_wrapper(const char * name) {
IOServiceNameMatching(name); }
CF_RETURNS_RETAINED CFDictionaryRef CreateDict(void);
void IOServiceAddNotification_wrapper(mach_port_t mainPort, const io_name_t notificationType,
mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) {
CFDictionaryRef matching = CreateDict();
CFRelease(matching);
IOServiceAddNotification(mainPort, notificationType, matching, wakePort, reference, notification);
}
void IORegistryEntryIDMatching_wrapper(uint64_t entryID ) {
IORegistryEntryIDMatching(entryID); }
void IOOpenFirmwarePathMatching_wrapper(mach_port_t mainPort, uint32_t options,
const char * path) {
IOOpenFirmwarePathMatching(mainPort, options, path); }
void IOServiceGetMatchingService_wrapper(mach_port_t mainPort) {
CFDictionaryRef matching = CreateDict();
IOServiceGetMatchingService(mainPort, matching);
CFRelease(matching); }
void IOServiceGetMatchingServices_wrapper(mach_port_t mainPort, io_iterator_t *existing) {
CFDictionaryRef matching = CreateDict();
IOServiceGetMatchingServices(mainPort, matching, existing);
CFRelease(matching); }
void IOServiceAddMatchingNotification_wrapper(IONotificationPortRef notifyPort, const io_name_t notificationType,
IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification) {
CFDictionaryRef matching = CreateDict();
IOServiceAddMatchingNotification(notifyPort, notificationType, matching, callback, refCon, notification);
CFRelease(matching); }
void CFDictionaryAddValue(CFMutableDictionaryRef, void *, void *);
void rdar_6539791(CFMutableDictionaryRef y, void* key, void* val_key) {
CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionaryAddValue(y, key, x);
CFRelease(x); signed z = 1;
CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z);
if (value) {
CFDictionaryAddValue(x, val_key, (void*)value); CFRelease(value);
CFDictionaryAddValue(y, val_key, (void*)value); }
}
void rdar_6560661(CFMutableArrayRef x) {
signed z = 1;
CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z);
CFArrayAppendValue(x, value);
CFRelease(value);
CFRetain(value);
CFRelease(value); }
void rdar_7152619(CFStringRef str) {
CFAttributedStringRef string = CFAttributedStringCreate(kCFAllocatorDefault, str, 0);
CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutableCopy(kCFAllocatorDefault, 100, string);
CFRelease(string);
NSNumber *number = [[NSNumber alloc] initWithInt:5]; CFAttributedStringSetAttribute(attrString, CFRangeMake(0, 1), str, number);
[number release];
[number retain];
CFRelease(attrString);
}
void rdar_7184450(CGContextRef myContext, CGFloat x, CGPoint myStartPoint,
CGPoint myEndPoint) {
size_t num_locations = 6;
CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 };
CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0,
x, 207.0/255.0, 39.0/255.0, 39.0/255.0, x,
147.0/255.0, 21.0/255.0, 22.0/255.0, x,
175.0/255.0, 175.0/255.0, 175.0/255.0, x,
255.0/255.0,255.0/255.0, 255.0/255.0, x,
255.0/255.0,255.0/255.0, 255.0/255.0, x
};
CGGradientRef myGradient =
CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), components, locations, num_locations);
CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint,
0);
CGGradientRelease(myGradient);
}
void rdar_7184450_pos(CGContextRef myContext, CGFloat x, CGPoint myStartPoint,
CGPoint myEndPoint) {
size_t num_locations = 6;
CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 };
CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0,
x, 207.0/255.0, 39.0/255.0, 39.0/255.0, x,
147.0/255.0, 21.0/255.0, 22.0/255.0, x,
175.0/255.0, 175.0/255.0, 175.0/255.0, x,
255.0/255.0,255.0/255.0, 255.0/255.0, x,
255.0/255.0,255.0/255.0, 255.0/255.0, x
};
CGGradientRef myGradient =
CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), components, locations, num_locations);
CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint,
0);
}
struct _opaque_pthread_t {};
struct _opaque_pthread_attr_t {};
typedef struct _opaque_pthread_t *__darwin_pthread_t;
typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t;
typedef __darwin_pthread_t pthread_t;
typedef __darwin_pthread_attr_t pthread_attr_t;
typedef unsigned long __darwin_pthread_key_t;
typedef __darwin_pthread_key_t pthread_key_t;
int pthread_create(pthread_t *, const pthread_attr_t *,
void *(*)(void *), void *);
int pthread_setspecific(pthread_key_t key, const void *value);
void *rdar_7299394_start_routine(void *p) {
[((id) p) release];
return 0;
}
void rdar_7299394(pthread_attr_t *attr, pthread_t *thread, void *args) {
NSNumber *number = [[NSNumber alloc] initWithInt:5]; pthread_create(thread, attr, rdar_7299394_start_routine, number);
}
void rdar_7299394_positive(pthread_attr_t *attr, pthread_t *thread) {
NSNumber *number = [[NSNumber alloc] initWithInt:5]; }
void rdar11282706(pthread_key_t key) {
NSNumber *number = [[NSNumber alloc] initWithInt:5]; pthread_setspecific(key, (void*) number);
}
typedef int int32_t;
typedef UInt32 FourCharCode;
typedef FourCharCode OSType;
typedef uint64_t CVOptionFlags;
typedef int32_t CVReturn;
typedef struct __CVBuffer *CVBufferRef;
typedef CVBufferRef CVImageBufferRef;
typedef CVImageBufferRef CVPixelBufferRef;
typedef void (*CVPixelBufferReleaseBytesCallback)( void *releaseRefCon, const void *baseAddress );
extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator,
size_t width,
size_t height,
OSType pixelFormatType,
void *baseAddress,
size_t bytesPerRow,
CVPixelBufferReleaseBytesCallback releaseCallback,
void *releaseRefCon,
CFDictionaryRef pixelBufferAttributes,
CVPixelBufferRef *pixelBufferOut) ;
typedef void (*CVPixelBufferReleasePlanarBytesCallback)( void *releaseRefCon, const void *dataPtr, size_t dataSize, size_t numberOfPlanes, const void *planeAddresses[] );
extern CVReturn CVPixelBufferCreateWithPlanarBytes(CFAllocatorRef allocator,
size_t width,
size_t height,
OSType pixelFormatType,
void *dataPtr,
size_t dataSize,
size_t numberOfPlanes,
void *planeBaseAddress[],
size_t planeWidth[],
size_t planeHeight[],
size_t planeBytesPerRow[],
CVPixelBufferReleasePlanarBytesCallback releaseCallback,
void *releaseRefCon,
CFDictionaryRef pixelBufferAttributes,
CVPixelBufferRef *pixelBufferOut) ;
extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator,
size_t width,
size_t height,
OSType pixelFormatType,
void *baseAddress,
size_t bytesPerRow,
CVPixelBufferReleaseBytesCallback releaseCallback,
void *releaseRefCon,
CFDictionaryRef pixelBufferAttributes,
CVPixelBufferRef *pixelBufferOut) ;
CVReturn rdar_7283567(CFAllocatorRef allocator, size_t width, size_t height,
OSType pixelFormatType, void *baseAddress,
size_t bytesPerRow,
CVPixelBufferReleaseBytesCallback releaseCallback,
CFDictionaryRef pixelBufferAttributes,
CVPixelBufferRef *pixelBufferOut) {
NSNumber *number = [[NSNumber alloc] initWithInt:5];
return CVPixelBufferCreateWithBytes(allocator, width, height, pixelFormatType,
baseAddress, bytesPerRow, releaseCallback,
number, pixelBufferAttributes, pixelBufferOut) ;
}
CVReturn rdar_7283567_2(CFAllocatorRef allocator, size_t width, size_t height,
OSType pixelFormatType, void *dataPtr, size_t dataSize,
size_t numberOfPlanes, void *planeBaseAddress[],
size_t planeWidth[], size_t planeHeight[], size_t planeBytesPerRow[],
CVPixelBufferReleasePlanarBytesCallback releaseCallback,
CFDictionaryRef pixelBufferAttributes,
CVPixelBufferRef *pixelBufferOut) {
NSNumber *number = [[NSNumber alloc] initWithInt:5];
return CVPixelBufferCreateWithPlanarBytes(allocator,
width, height, pixelFormatType, dataPtr, dataSize,
numberOfPlanes, planeBaseAddress, planeWidth,
planeHeight, planeBytesPerRow, releaseCallback,
number, pixelBufferAttributes, pixelBufferOut) ;
}
typedef uint32_t CGBitmapInfo;
typedef void (*CGBitmapContextReleaseDataCallback)(void *releaseInfo, void *data);
CGContextRef CGBitmapContextCreateWithData(void *data,
size_t width, size_t height, size_t bitsPerComponent,
size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo,
CGBitmapContextReleaseDataCallback releaseCallback, void *releaseInfo);
void rdar_7358899(void *data,
size_t width, size_t height, size_t bitsPerComponent,
size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo,
CGBitmapContextReleaseDataCallback releaseCallback) {
NSNumber *number = [[NSNumber alloc] initWithInt:5];
CGBitmapContextCreateWithData(data, width, height, bitsPerComponent, bytesPerRow, space, bitmapInfo, releaseCallback, number);
}
@interface RDar7265711 {}
- (id) new_stuff;
@end
void rdar7265711_a(RDar7265711 *x) {
id y = [x new_stuff]; }
void rdar7265711_b(RDar7265711 *x) {
id y = [x new_stuff]; [y release];
}
@interface NSCursor : NSObject
+ (NSCursor *)dragCopyCursor;
@end
void rdar7306898(void) {
NSCursor *c = [NSCursor dragCopyCursor]; NSNumber *number = [[NSNumber alloc] initWithInt:5]; }
@interface RDar7252064 : NSObject @end
void rdar7252064(void) {
[RDar7252064 release]; [RDar7252064 retain]; [RDar7252064 autorelease]; [NSAutoreleasePool drain]; }
typedef NSString* MyStringTy;
@protocol FooP;
@interface TestOwnershipAttr : NSObject
- (NSString*) returnsAnOwnedString NS_RETURNS_RETAINED; - (NSString*) returnsAnOwnedCFString CF_RETURNS_RETAINED; - (MyStringTy) returnsAnOwnedTypedString NS_RETURNS_RETAINED; - (NSString*) newString NS_RETURNS_NOT_RETAINED; - (NSString*) newString_auto NS_RETURNS_AUTORELEASED; - (NSString*) newStringNoAttr;
- (int) returnsAnOwnedInt NS_RETURNS_RETAINED; - (id) pseudoInit NS_CONSUMES_SELF NS_RETURNS_RETAINED;
+ (void) consume:(id) NS_CONSUMED x;
+ (void) consume2:(id) CF_CONSUMED x;
@end
static int ownership_attribute_doesnt_go_here NS_RETURNS_RETAINED;
void test_attr_1(TestOwnershipAttr *X) {
NSString *str = [X returnsAnOwnedString]; }
void test_attr_1b(TestOwnershipAttr *X) {
NSString *str = [X returnsAnOwnedCFString]; }
void test_attr1c(TestOwnershipAttr *X) {
NSString *str = [X newString]; NSString *str2 = [X newStringNoAttr]; NSString *str3 = [X newString_auto]; NSString *str4 = [[X newString_auto] retain]; }
void testattr2_a(void) {
TestOwnershipAttr *x = [TestOwnershipAttr alloc]; }
void testattr2_b(void) {
TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; }
void testattr2_b_11358224_self_assign_looses_the_leak(void) {
TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; x = x;
}
void testattr2_c(void) {
TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; [x release];
}
void testattr3(void) {
TestOwnershipAttr *x = [TestOwnershipAttr alloc]; [TestOwnershipAttr consume:x];
TestOwnershipAttr *y = [TestOwnershipAttr alloc]; [TestOwnershipAttr consume2:y];
}
void consume_ns(id NS_CONSUMED x);
void consume_cf(id CF_CONSUMED x);
void testattr4(void) {
TestOwnershipAttr *x = [TestOwnershipAttr alloc]; consume_ns(x);
TestOwnershipAttr *y = [TestOwnershipAttr alloc]; consume_cf(y);
}
@interface TestOwnershipAttr2 : NSObject
- (NSString*) newString NS_RETURNS_NOT_RETAINED; @end
@implementation TestOwnershipAttr2
- (NSString*) newString {
return [NSString alloc]; }
@end
@interface MyClassTestCFAttr : NSObject {}
- (NSDate*) returnsCFRetained CF_RETURNS_RETAINED;
- (CFDateRef) returnsCFRetainedAsCF CF_RETURNS_RETAINED;
- (CFDateRef) newCFRetainedAsCF CF_RETURNS_NOT_RETAINED;
- (CFDateRef) newCFRetainedAsCFNoAttr;
- (NSDate*) alsoReturnsRetained;
- (CFDateRef) alsoReturnsRetainedAsCF;
- (NSDate*) returnsNSRetained NS_RETURNS_RETAINED;
@end
CF_RETURNS_RETAINED
CFDateRef returnsRetainedCFDate(void) {
return CFDateCreate(0, CFAbsoluteTimeGetCurrent());
}
@implementation MyClassTestCFAttr
- (NSDate*) returnsCFRetained {
return (NSDate*) returnsRetainedCFDate(); }
- (CFDateRef) returnsCFRetainedAsCF {
return returnsRetainedCFDate(); }
- (CFDateRef) newCFRetainedAsCF {
return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease];
}
- (CFDateRef) newCFRetainedAsCFNoAttr {
return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease]; }
- (NSDate*) alsoReturnsRetained {
return (NSDate*) returnsRetainedCFDate(); }
- (CFDateRef) alsoReturnsRetainedAsCF {
return returnsRetainedCFDate(); }
- (NSDate*) returnsNSRetained {
return (NSDate*) returnsRetainedCFDate(); }
@end
void panic(void) __attribute__((noreturn));
void panic_not_in_hardcoded_list(void) __attribute__((noreturn));
void test_panic_negative(void) {
signed z = 1;
CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); }
void test_panic_positive(void) {
signed z = 1;
CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); panic();
}
void test_panic_neg_2(int x) {
signed z = 1;
CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); if (x)
panic();
}
void test_panic_pos_2(int x) {
signed z = 1;
CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); if (x)
panic();
if (!x) {
panic_not_in_hardcoded_list();
}
}
void test_blocks_1_pos(void) {
NSNumber *number = [[NSNumber alloc] initWithInt:5]; ^{}();
}
void test_blocks_1_indirect_release(void) {
NSNumber *number = [[NSNumber alloc] initWithInt:5]; ^{ [number release]; }();
}
void test_blocks_1_indirect_retain(void) {
NSNumber *number = [[NSNumber alloc] initWithInt:5]; ^{ [number retain]; }();
}
void test_blocks_1_indirect_release_via_call(void) {
NSNumber *number = [[NSNumber alloc] initWithInt:5]; ^(NSObject *o){ [o release]; }(number);
}
void test_blocks_1_indirect_retain_via_call(void) {
NSNumber *number = [[NSNumber alloc] initWithInt:5]; ^(NSObject *o){ [o retain]; }(number);
}
@interface Rdar8015556 : NSObject {} @end
@implementation Rdar8015556
- (id)retain {
return [super retain];
}
@end
@protocol Prot_R8272168 @end
Class <Prot_R8272168> GetAClassThatImplementsProt_R8272168(void);
void r8272168(void) {
GetAClassThatImplementsProt_R8272168();
}
@interface RDar8356342
- (NSDate*) rdar8356342:(NSDate *)inValue;
@end
@implementation RDar8356342
- (NSDate*) rdar8356342:(NSDate*)inValue {
NSDate *outValue = inValue;
if (outValue == 0)
outValue = [[NSDate alloc] init];
if (outValue != inValue)
[outValue autorelease];
return outValue;
}
@end
extern const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key);
typedef struct __CFError * CFErrorRef;
extern const CFStringRef kCFErrorUnderlyingErrorKey;
extern CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err);
static void rdar_8724287(CFErrorRef error)
{
CFErrorRef error_to_dump;
error_to_dump = error;
while (error_to_dump != ((void*)0)) {
CFDictionaryRef info;
info = CFErrorCopyUserInfo(error_to_dump);
if (info != ((void*)0)) {
}
error_to_dump = (CFErrorRef) CFDictionaryGetValue(info, kCFErrorUnderlyingErrorKey);
}
}
extern void *CFStringCreate(void);
extern void rdar_9234108_helper(void *key, void * CF_CONSUMED value);
void rdar_9234108(void) {
rdar_9234108_helper(0, CFStringCreate());
}
struct TwoDoubles {
double one;
double two;
};
typedef struct TwoDoubles TwoDoubles;
@interface NSValue (Mine)
- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles __attribute__((objc_method_family(init)));
@end
@implementation NSValue (Mine)
- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles
{
return [self init];
}
@end
void rdar9726279(void) {
TwoDoubles twoDoubles = { 0.0, 0.0 };
NSValue *value = [[NSValue alloc] _prefix_initWithTwoDoubles:twoDoubles];
[value release];
}
CFArrayRef camelcase_create_1(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
CFArrayRef camelcase_createno(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
CFArrayRef camelcase_copy(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
CFArrayRef camelcase_copying(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
CFArrayRef copyCamelCase(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
CFArrayRef __copyCamelCase(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
CFArrayRef __createCamelCase(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
CFArrayRef camel_create(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
CFArrayRef camel_creat(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
CFArrayRef camel_copy(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
CFArrayRef camel_copyMachine(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
CFArrayRef camel_copymachine(void) {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); }
@protocol F18P
- (id) clone;
@end
@interface F18 : NSObject<F18P> @end
@interface F18(Cat)
- (id) clone NS_RETURNS_RETAINED;
@end
@implementation F18
- (id) clone {
return [F18 alloc];
}
@end
void rdar6582778(void) {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFTypeRef vals[] = { CFDateCreate(0, t) }; }
CFTypeRef global;
void rdar6582778_2(void) {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
global = CFDateCreate(0, t); }
void rdar10232019(void) {
NSMutableArray *array = [NSMutableArray array];
NSString *string = [[NSString alloc] initWithUTF8String:"foo"];
[array addObject:string];
[string release];
NSString *otherString = [string stringByAppendingString:@"bar"]; NSLog(@"%@", otherString);
}
void rdar10232019_positive(void) {
NSMutableArray *array = [NSMutableArray array];
NSString *string = [[NSString alloc] initWithUTF8String:"foo"];
[string release];
NSString *otherString = [string stringByAppendingString:@"bar"]; NSLog(@"%@", otherString);
}
typedef void * xpc_object_t;
xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef cf);
void xpc_release(xpc_object_t object);
void rdar9658496(void) {
CFStringRef cf;
xpc_object_t xpc;
cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); xpc = _CFXPCCreateXPCObjectFromCFObject( cf );
CFRelease(cf);
xpc_release(xpc);
}
@interface RDar10824732 : NSObject
- (id)initWithObj:(id CF_CONSUMED)obj;
@end
@implementation RDar10824732
- (id)initWithObj:(id)obj {
[obj release];
return [super init];
}
@end
void rdar_10824732(void) {
@autoreleasepool {
NSString *obj = @"test";
RDar10824732 *foo = [[RDar10824732 alloc] initWithObj:obj]; [foo release];
}
}
typedef int (*CloseCallback) (void *);
void ReaderForIO(CloseCallback ioclose, void *ioctx);
int IOClose(void *context);
@protocol SInS <NSObject>
@end
@interface radar10973977 : NSObject
- (id<SInS>)inputS;
- (void)reader;
@end
@implementation radar10973977
- (void)reader
{
id<SInS> inputS = [[self inputS] retain];
ReaderForIO(IOClose, inputS);
}
- (id<SInS>)inputS
{
return 0;
}
@end
extern id NSApp;
@interface MySheetController
- (id<SInS>)inputS;
- (void)showDoSomethingSheetAction:(id)action;
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
@end
@implementation MySheetController
- (id<SInS>)inputS {
return 0;
}
- (void)showDoSomethingSheetAction:(id)action {
id<SInS> inputS = [[self inputS] retain];
[NSApp beginSheet:0
modalForWindow:0
modalDelegate:0
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:(void *)inputS]; }
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo {
id contextObject = (id)contextInfo;
[contextObject release];
}
- (id)copyAutoreleaseRadar13081402 {
id x = [[[NSString alloc] initWithUTF8String:"foo"] autorelease];
[x retain];
return x; }
@end
void *malloc(size_t);
struct rdar11104566 { CFStringRef myStr; };
struct rdar11104566 test_rdar11104566(void) {
CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); struct rdar11104566 V;
V.myStr = cf;
return V; }
struct rdar11104566 *test_2_rdar11104566(void) {
CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); struct rdar11104566 *V = (struct rdar11104566 *) malloc(sizeof(*V));
V->myStr = cf;
return V; }
void test_objc_arrays(void) {
{ NSObject *o = [[NSObject alloc] init];
NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0]; [o release];
[a description];
[o description];
}
{ NSObject *o = [[NSObject alloc] init];
NSArray *a1 = [NSArray arrayWithObjects:o, (void*)0];
NSArray *a2 = [[NSArray alloc] initWithArray:a1]; [o release];
[a2 description];
[o description];
}
{ NSObject *o = [[NSObject alloc] init];
NSArray *a3 = [@[o] retain]; [o release];
[a3 description];
[o description];
}
{ NSObject *o = [[NSObject alloc] init];
NSArray *a = [[NSArray alloc] initWithArray:@[o]]; [o release];
[a description];
[o description];
}
{ NSValue *o = [[NSValue alloc] init];
NSDictionary *a = [@{o : o} retain]; [o release];
[a description];
[o description];
}
}
void test_objc_integer_literals(void) {
id value = [@1 retain]; [value description];
}
void test_objc_boxed_expressions(int x, const char *y) {
id value = [@(x) retain]; [value description];
value = [@(y) retain]; [value description];
}
void rdar11400885(int y)
{
@autoreleasepool {
NSString *printString;
if(y > 2)
printString = [[NSString alloc] init];
else
printString = [[NSString alloc] init];
NSLog(@"Once %@", printString);
[printString release];
NSLog(@"Again: %@", printString); }
}
id makeCollectableNonLeak(void) {
extern CFTypeRef CFCreateSomething(void);
CFTypeRef object = CFCreateSomething(); CFRetain(object); id objCObject = NSMakeCollectable(object); [objCObject release]; return [objCObject autorelease]; }
void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void));
void CFConsumeAndStopTracking(CFTypeRef CF_CONSUMED obj, void (^callback)(void));
void testConsumeAndStopTracking(void) {
id retained = [@[] retain]; consumeAndStopTracking(retained, ^{});
id doubleRetained = [[@[] retain] retain]; consumeAndStopTracking(doubleRetained, ^{
[doubleRetained release];
});
id unretained = @[]; consumeAndStopTracking(unretained, ^{}); }
void testCFConsumeAndStopTracking(void) {
id retained = [@[] retain]; CFConsumeAndStopTracking((CFTypeRef)retained, ^{});
id doubleRetained = [[@[] retain] retain]; CFConsumeAndStopTracking((CFTypeRef)doubleRetained, ^{
[doubleRetained release];
});
id unretained = @[]; CFConsumeAndStopTracking((CFTypeRef)unretained, ^{}); }
typedef void *MyCFType;
#pragma clang arc_cf_code_audited begin
MyCFType CreateMyCFType(void);
#pragma clang arc_cf_code_audited end
void test_custom_cf(void) {
MyCFType x = CreateMyCFType(); }
void test_CFPlugInInstanceCreate(CFUUIDRef factoryUUID, CFUUIDRef typeUUID) {
CFPlugInInstanceCreate(kCFAllocatorDefault, factoryUUID, typeUUID); }
@interface PR14927 : NSObject
- (void)drain;
@end
void test_drain(void) {
PR14927 *obj = [[PR14927 alloc] init];
[obj drain];
[obj release]; }
MyCFType getCustom(void) __attribute__((cf_returns_not_retained));
MyCFType makeCustom(void) __attribute__((cf_returns_retained));
void testCustomReturnsRetained(void) {
MyCFType obj = makeCustom(); }
void testCustomReturnsNotRetained(void) {
CFRelease(getCustom()); }
@interface MyObj12706177 : NSObject
-(id)initX;
+(void)test12706177;
@end
static int Cond;
@implementation MyObj12706177
-(id)initX {
if (Cond)
return 0;
self = [super init];
return self;
}
+(void)test12706177 {
id x = [[MyObj12706177 alloc] initX]; [x release];
}
@end
typedef xpc_object_t xpc_connection_t;
typedef void (*xpc_finalizer_t)(void *value);
void xpc_connection_set_context(xpc_connection_t connection, void *ctx);
void xpc_connection_set_finalizer_f(xpc_connection_t connection,
xpc_finalizer_t finalizer);
void releaseAfterXPC(void *context) {
[(NSArray *)context release];
}
void rdar13783514(xpc_connection_t connection) {
xpc_connection_set_context(connection, [[NSMutableArray alloc] init]);
xpc_connection_set_finalizer_f(connection, releaseAfterXPC);
}
CFAttributedStringRef CFAttributedCreate(void *CFObj CF_CONSUMED) CF_RETURNS_RETAINED;
@interface Action
- (SEL)action;
- (void)setAction:(SEL)aSelector;
- (id) target;
- (void)setTarget:(id)aTarget;
@end