1 // RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -pedantic -analyzer-store=region -verify %s 2 3 // BEGIN delta-debugging reduced header stuff 4 5 typedef signed char BOOL; 6 typedef unsigned int NSUInteger; 7 typedef struct _NSZone NSZone; 8 @class NSCoder; 9 @protocol NSObject 10 - (BOOL)isEqual:(id)object; 11 - (id)retain; 12 - (oneway void)release; 13 @end 14 @protocol NSCopying 15 - (id)copyWithZone:(NSZone *)zone; 16 @end 17 @protocol NSCoding 18 - (void)encodeWithCoder:(NSCoder *)aCoder; 19 @end 20 @interface NSObject <NSObject> {} 21 - (id)init; 22 + (id)alloc; 23 @end 24 typedef double NSTimeInterval; 25 enum { NSAnimationEaseInOut, NSAnimationEaseIn, NSAnimationEaseOut, NSAnimationLinear }; 26 typedef NSUInteger NSAnimationCurve; 27 @interface NSAnimation : NSObject <NSCopying, NSCoding> {} 28 - (id)initWithDuration:(NSTimeInterval)duration animationCurve:(NSAnimationCurve)animationCurve; 29 - (void)startAnimation; 30 - (void)setDelegate:(id)delegate; 31 @end 32 33 // END delta-debugging reduced header stuff 34 35 // From NSAnimation Class Reference 36 // -(void)startAnimation 37 // The receiver retains itself and is then autoreleased at the end 38 // of the animation or when it receives stopAnimation. 39 40 @interface MyClass { } 41 - (void)animationDidEnd:(NSAnimation *)animation; 42 @end 43 44 @implementation MyClass 45 - (void)f1 { 46 // NOTE: The analyzer doesn't really handle this; it just stops tracking 47 // 'animation' when it is sent the message 'setDelegate:'. 48 NSAnimation *animation = [[NSAnimation alloc] // no-warning 49 initWithDuration:1.0 50 animationCurve:NSAnimationEaseInOut]; 51 52 [animation setDelegate:self]; 53 [animation startAnimation]; 54 } 55 56 - (void)f2 { 57 NSAnimation *animation = [[NSAnimation alloc] // expected-warning{{leak}} 58 initWithDuration:1.0 59 animationCurve:NSAnimationEaseInOut]; 60 61 [animation startAnimation]; 62 } 63 64 - (void)animationDidEnd:(NSAnimation *)animation { 65 [animation release]; 66 } 67 @end 68