68 lines · plain
1// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -pedantic -verify -Wno-objc-root-class %s2 3// BEGIN delta-debugging reduced header stuff4 5typedef signed char BOOL;6typedef unsigned int NSUInteger;7typedef struct _NSZone NSZone;8@class NSCoder;9@protocol NSObject10- (BOOL)isEqual:(id)object;11- (id)retain;12- (oneway void)release;13@end14@protocol NSCopying15- (id)copyWithZone:(NSZone *)zone;16@end17@protocol NSCoding18- (void)encodeWithCoder:(NSCoder *)aCoder;19@end20@interface NSObject <NSObject> {}21- (id)init;22+ (id)alloc;23@end24typedef double NSTimeInterval;25enum { NSAnimationEaseInOut, NSAnimationEaseIn, NSAnimationEaseOut, NSAnimationLinear };26typedef 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@end32 33// END delta-debugging reduced header stuff34 35// From NSAnimation Class Reference36// -(void)startAnimation37// 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@end43 44@implementation MyClass45- (void)f1 { 46 // NOTE: The analyzer doesn't really handle this; it just stops tracking47 // 'animation' when it is sent the message 'setDelegate:'.48 NSAnimation *animation = [[NSAnimation alloc] // no-warning49 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@end68