aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/pr_2542_rdar_6793404.m
blob: 761448caf952e58528e45a3fe3eb64e2ad64b850 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// RUN: clang -cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -pedantic -analyzer-store=basic -verify %s
// RUN: clang -cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -pedantic -analyzer-store=region -verify %s

// BEGIN delta-debugging reduced header stuff

typedef signed char BOOL;
typedef unsigned int NSUInteger;
typedef struct _NSZone NSZone;
@class NSCoder;
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (id)retain;
- (oneway void)release;
@end
@protocol NSCopying
- (id)copyWithZone:(NSZone *)zone;
@end
@protocol NSCoding
- (void)encodeWithCoder:(NSCoder *)aCoder;
@end
@interface NSObject <NSObject> {}
- (id)init;
+ (id)alloc;
@end
typedef double NSTimeInterval;
enum { NSAnimationEaseInOut, NSAnimationEaseIn, NSAnimationEaseOut, NSAnimationLinear };
typedef NSUInteger NSAnimationCurve;
@interface NSAnimation : NSObject <NSCopying, NSCoding> {}
- (id)initWithDuration:(NSTimeInterval)duration animationCurve:(NSAnimationCurve)animationCurve;
- (void)startAnimation;
- (void)setDelegate:(id)delegate;
@end

// END delta-debugging reduced header stuff

// From NSAnimation Class Reference
// -(void)startAnimation
// The receiver retains itself and is then autoreleased at the end 
// of the animation or when it receives stopAnimation.

@interface MyClass { }
- (void)animationDidEnd:(NSAnimation *)animation;
@end

@implementation MyClass
- (void)f1 {  
  // NOTE: The analyzer doesn't really handle this; it just stops tracking
  // 'animation' when it is sent the message 'setDelegate:'.
  NSAnimation *animation = [[NSAnimation alloc]   // no-warning
                            initWithDuration:1.0 
                            animationCurve:NSAnimationEaseInOut];
  
  [animation setDelegate:self];
  [animation startAnimation]; 
}

- (void)f2 {
  NSAnimation *animation = [[NSAnimation alloc]  // expected-warning{{leak}}
                            initWithDuration:1.0 
                            animationCurve:NSAnimationEaseInOut];

  [animation startAnimation]; 
}

- (void)animationDidEnd:(NSAnimation *)animation {
  [animation release];
}
@end