Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / pr_2542_rdar_6793404.m
blob4b6936d86ea2ddc9108c6d5ba55d8fdd07c328b9
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -pedantic -verify -Wno-objc-root-class %s
3 // BEGIN delta-debugging reduced header stuff
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
33 // END delta-debugging reduced header stuff
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.
40 @interface MyClass { }
41 - (void)animationDidEnd:(NSAnimation *)animation;
42 @end
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]; 
56 - (void)f2 {
57   NSAnimation *animation = [[NSAnimation alloc]  // expected-warning{{leak}}
58                             initWithDuration:1.0 
59                             animationCurve:NSAnimationEaseInOut];
61   [animation startAnimation]; 
64 - (void)animationDidEnd:(NSAnimation *)animation {
65   [animation release];
67 @end