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