retain-release-gc-only.m revision be1fe1eb12a1cb91c8e3a9fcc2db4dfe989def6c
1// RUN: clang -analyze -checker-cfref -verify -fobjc-gc-only %s &&
2// RUN: clang -analyze -checker-cfref -analyzer-store=region -fobjc-gc-only -verify %s
3
4//===----------------------------------------------------------------------===//
5// Header stuff.
6//===----------------------------------------------------------------------===//
7typedef unsigned int __darwin_natural_t;
8typedef unsigned long UInt32;
9typedef signed long CFIndex;
10typedef const void * CFTypeRef;
11typedef const struct __CFString * CFStringRef;
12typedef const struct __CFAllocator * CFAllocatorRef;
13extern const CFAllocatorRef kCFAllocatorDefault;
14extern CFTypeRef CFRetain(CFTypeRef cf);
15extern void CFRelease(CFTypeRef cf);
16typedef struct {
17}
18  CFArrayCallBacks;
19extern const CFArrayCallBacks kCFTypeArrayCallBacks;
20typedef const struct __CFArray * CFArrayRef;
21typedef struct __CFArray * CFMutableArrayRef;
22extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks);
23extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
24typedef const struct __CFDictionary * CFDictionaryRef;
25typedef UInt32 CFStringEncoding;
26enum {
27kCFStringEncodingMacRoman = 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  };
28extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding);
29typedef double CFTimeInterval;
30typedef CFTimeInterval CFAbsoluteTime;
31typedef const struct __CFDate * CFDateRef;
32extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at);
33extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate);
34typedef __darwin_natural_t natural_t;
35typedef natural_t mach_port_name_t;
36typedef mach_port_name_t mach_port_t;
37typedef signed char BOOL;
38typedef struct _NSZone NSZone;
39@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
40@protocol NSObject  - (BOOL)isEqual:(id)object;
41- (id)retain;
42- (oneway void)release;
43- (id)autorelease;
44@end  @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
45@end  @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder;
46@end    @interface NSObject <NSObject> {
47}
48@end  typedef float CGFloat;
49typedef double NSTimeInterval;
50@interface NSDate : NSObject <NSCopying, NSCoding>  - (NSTimeInterval)timeIntervalSinceReferenceDate;
51@end      enum {
52NSObjCNoType = 0,     NSObjCVoidType = 'v',     NSObjCCharType = 'c',     NSObjCShortType = 's',     NSObjCLongType = 'l',     NSObjCLonglongType = 'q',     NSObjCFloatType = 'f',     NSObjCDoubleType = 'd',      NSObjCBoolType = 'B',      NSObjCSelectorType = ':',     NSObjCObjectType = '@',     NSObjCStructType = '{',     NSObjCPointerType = '^',     NSObjCStringType = '*',     NSObjCArrayType = '[',     NSObjCUnionType = '(',     NSObjCBitfield = 'b' }
53__attribute__((deprecated));
54typedef int kern_return_t;
55typedef kern_return_t mach_error_t;
56typedef mach_port_t io_object_t;
57typedef io_object_t io_service_t;
58typedef struct __DASession * DASessionRef;
59extern DASessionRef DASessionCreate( CFAllocatorRef allocator );
60typedef struct __DADisk * DADiskRef;
61extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name );
62extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media );
63extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk );
64extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk );
65@interface NSAppleEventManager : NSObject {
66}
67@end enum {
68kDAReturnSuccess = 0,     kDAReturnError = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01,     kDAReturnBusy = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02,     kDAReturnBadArgument = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03,     kDAReturnExclusiveAccess = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04,     kDAReturnNoResources = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05,     kDAReturnNotFound = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06,     kDAReturnNotMounted = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07,     kDAReturnNotPermitted = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08,     kDAReturnNotPrivileged = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09,     kDAReturnNotReady = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A,     kDAReturnNotWritable = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B,     kDAReturnUnsupported = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C };
69typedef mach_error_t DAReturn;
70typedef const struct __DADissenter * DADissenterRef;
71extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string );
72
73//===----------------------------------------------------------------------===//
74// Test cases.
75//===----------------------------------------------------------------------===//
76
77void f1() {
78  CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
79  id x = [(id) A autorelease];
80  CFRelease((CFMutableArrayRef) x); // no-warning
81}
82