[cfe-commits] r70350 - /cfe/trunk/test/Analysis/retain-release.m

Ted Kremenek kremenek at apple.com
Tue Apr 28 17:41:45 PDT 2009


Author: kremenek
Date: Tue Apr 28 19:41:31 2009
New Revision: 70350

URL: http://llvm.org/viewvc/llvm-project?rev=70350&view=rev
Log:
Add regression test case provided by <rdar://problem/6833332>.

Modified:
    cfe/trunk/test/Analysis/retain-release.m

Modified: cfe/trunk/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=70350&r1=70349&r2=70350&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Tue Apr 28 19:41:31 2009
@@ -12,8 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 typedef unsigned int __darwin_natural_t;
-typedef struct {} div_t;
-typedef unsigned long UInt32;
+typedef unsigned int UInt32;
 typedef signed long CFIndex;
 typedef const void * CFTypeRef;
 typedef const struct __CFString * CFStringRef;
@@ -44,11 +43,11 @@
 typedef __darwin_natural_t natural_t;
 typedef natural_t mach_port_name_t;
 typedef mach_port_name_t mach_port_t;
-typedef struct {
-}
-CFRunLoopObserverContext;
+typedef int kern_return_t;
+typedef kern_return_t mach_error_t;
+typedef struct objc_selector *SEL;
 typedef signed char BOOL;
-typedef unsigned int NSUInteger;
+typedef unsigned long NSUInteger;
 @class NSString, Protocol;
 extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
 typedef struct _NSZone NSZone;
@@ -60,25 +59,30 @@
 @end  @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
 @end  @protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone;
 @end  @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder;
- at end
- at interface NSObject <NSObject> {}
-+ (id)alloc;
+ at end    @interface NSObject <NSObject> {
+}
 + (id)allocWithZone:(NSZone *)zone;
- at end   typedef float CGFloat;
++ (id)alloc;
+- (void)dealloc;
+ at end      extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+}
+NSFastEnumerationState;
+ at protocol NSFastEnumeration  - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+ at end           @class NSString, NSDictionary;
+typedef double NSTimeInterval;
+ at interface NSDate : NSObject <NSCopying, NSCoding>  - (NSTimeInterval)timeIntervalSinceReferenceDate;
+ at end            typedef unsigned short unichar;
 @interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>    - (NSUInteger)length;
-- (const char *)UTF8String;
+- ( const char *)UTF8String;
 - (id)initWithUTF8String:(const char *)nullTerminatedCString;
 + (id)stringWithUTF8String:(const char *)nullTerminatedCString;
-- (id)init;
-- (void)dealloc;
- at end   extern NSString * const NSCurrentLocaleDidChangeNotification ;
- at protocol NSLocking  - (void)lock;
- at end  extern NSString * const NSUndoManagerCheckpointNotification;
-typedef enum {
-ACL_READ_DATA = (1<<1),  ACL_LIST_DIRECTORY = (1<<1),  ACL_WRITE_DATA = (1<<2),  ACL_ADD_FILE = (1<<2),  ACL_EXECUTE = (1<<3),  ACL_SEARCH = (1<<3),  ACL_DELETE = (1<<4),  ACL_APPEND_DATA = (1<<5),  ACL_ADD_SUBDIRECTORY = (1<<5),  ACL_DELETE_CHILD = (1<<6),  ACL_READ_ATTRIBUTES = (1<<7),  ACL_WRITE_ATTRIBUTES = (1<<8),  ACL_READ_EXTATTRIBUTES = (1<<9),  ACL_WRITE_EXTATTRIBUTES = (1<<10),  ACL_READ_SECURITY = (1<<11),  ACL_WRITE_SECURITY = (1<<12),  ACL_CHANGE_OWNER = (1<<13) }
-acl_entry_id_t;
-typedef int kern_return_t;
-typedef kern_return_t mach_error_t;
+ at end        @class NSDictionary;
+ at interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>  - (NSUInteger)count;
+ at end    @interface NSMutableDictionary : NSDictionary  - (void)removeObjectForKey:(id)aKey;
+- (void)setObject:(id)anObject forKey:(id)aKey;
+ at end  @interface NSMutableDictionary (NSMutableDictionaryCreation)  + (id)dictionaryWithCapacity:(NSUInteger)numItems;
+ at end @class NSString, NSDictionary, NSArray;
 typedef mach_port_t io_object_t;
 typedef io_object_t io_service_t;
 typedef struct __DASession * DASessionRef;
@@ -88,16 +92,36 @@
 extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media );
 extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk );
 extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk );
+ at interface NSTask : NSObject - (id)init;
+ at end  extern NSString * const NSTaskDidTerminateNotification;
 @interface NSResponder : NSObject <NSCoding> {
+struct __vaFlags {
 }
- at end  @class NSColor, NSFont, NSNotification;
-typedef struct __CFlags {
+_vaFlags;
 }
-_CFlags;
- at interface NSCell : NSObject <NSCopying, NSCoding> {
+ at end    @protocol NSAnimatablePropertyContainer      - (id)animator;
+ at end  extern NSString *NSAnimationTriggerOrderIn ;
+ at class NSBitmapImageRep, NSCursor, NSGraphicsContext, NSImage, NSPasteboard, NSScrollView, NSTextInputContext, NSWindow, NSAttributedString;
+ at interface NSView : NSResponder  <NSAnimatablePropertyContainer>  {
+struct __VFlags2 {
 }
- at end  @class NSDate, NSDictionary, NSError, NSException, NSNotification;
- at interface NSManagedObjectContext : NSObject <NSCoding, NSLocking> {
+_vFlags2;
+}
+ at end  @class NSColor, NSFont, NSNotification;
+ at interface NSTextTab : NSObject <NSCopying, NSCoding> {
+}
+ at end @protocol NSValidatedUserInterfaceItem - (SEL)action;
+ at end   @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
+ at end @class NSArray, NSError, NSImage, NSView, NSNotificationCenter, NSURL, NSScreen, NSRunningApplication;
+ at interface NSApplication : NSResponder <NSUserInterfaceValidations> {
+}
+ at end   enum {
+NSTerminateCancel = 0,         NSTerminateNow = 1,         NSTerminateLater = 2 };
+typedef NSUInteger NSApplicationTerminateReply;
+ at protocol NSApplicationDelegate <NSObject> @optional        - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
+ at end    enum {
+NSUserInterfaceLayoutDirectionLeftToRight = 0,     NSUserInterfaceLayoutDirectionRightToLeft = 1 };
+ at interface NSManagedObject : NSObject {
 }
 @end enum {
 kDAReturnSuccess = 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 };
@@ -105,9 +129,6 @@
 typedef const struct __DADissenter * DADissenterRef;
 extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string );
 
-
-
-
 //===----------------------------------------------------------------------===//
 // Test cases.
 //===----------------------------------------------------------------------===//
@@ -469,3 +490,30 @@
   [X myCFRelease:str];
 }
 
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6833332>
+// One build of the analyzer accidentally stopped tracking the allocated
+// object after the 'retain'.
+//===----------------------------------------------------------------------===//                             
+
+ at interface rdar_6833332 : NSObject <NSApplicationDelegate> {
+    NSWindow *window;
+}
+ at property (nonatomic, retain) NSWindow *window;
+ at end
+
+ at implementation rdar_6833332
+ at synthesize window;
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
+ NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}}
+
+ [dict setObject:@"foo" forKey:@"bar"];
+
+ NSLog(@"%@", dict);
+}
+- (void)dealloc {
+    [window release];
+    [super dealloc];
+}
+ at end
+





More information about the cfe-commits mailing list