1*67e74705SXin Li// RUN: %clang_cc1 -analyze -analyze-function="myMethodWithY:withX:" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s 2*67e74705SXin Li 3*67e74705SXin Litypedef signed char BOOL; 4*67e74705SXin Litypedef unsigned int NSUInteger; 5*67e74705SXin Litypedef struct _NSZone NSZone; 6*67e74705SXin Li@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; 7*67e74705SXin Li@protocol NSObject - (BOOL)isEqual:(id)object; @end 8*67e74705SXin Li@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end 9*67e74705SXin Li@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end 10*67e74705SXin Li@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end 11*67e74705SXin Li@interface NSObject <NSObject> {} 12*67e74705SXin Li+(id)alloc; 13*67e74705SXin Li-(id)init; 14*67e74705SXin Li-(id)autorelease; 15*67e74705SXin Li-(id)copy; 16*67e74705SXin Li-(id)retain; 17*67e74705SXin Li@end 18*67e74705SXin Li@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> 19*67e74705SXin Li- (NSUInteger)length; 20*67e74705SXin Li-(id)initWithFormat:(NSString *)f,...; 21*67e74705SXin Li-(BOOL)isEqualToString:(NSString *)s; 22*67e74705SXin Li+ (id)string; 23*67e74705SXin Li@end 24*67e74705SXin Li 25*67e74705SXin Li@interface Test1 : NSObject { 26*67e74705SXin Li NSString *text; 27*67e74705SXin Li} 28*67e74705SXin Li-(id)myMethod; 29*67e74705SXin Li-(id)myMethodWithY:(int)Y withX:(int)X; 30*67e74705SXin Li 31*67e74705SXin Li@property (nonatomic, assign) NSString *text; 32*67e74705SXin Li@end 33*67e74705SXin Li 34*67e74705SXin Li@implementation Test1 35*67e74705SXin Li 36*67e74705SXin Li@synthesize text; 37*67e74705SXin Li 38*67e74705SXin Li-(id)myMethod { 39*67e74705SXin Li Test1 *cell = [[[Test1 alloc] init] autorelease]; 40*67e74705SXin Li 41*67e74705SXin Li NSString *string1 = [[NSString alloc] initWithFormat:@"test %f", 0.0]; // No warning: this function is not analized. 42*67e74705SXin Li cell.text = string1; 43*67e74705SXin Li 44*67e74705SXin Li return cell; 45*67e74705SXin Li} 46*67e74705SXin Li 47*67e74705SXin Li-(id)myMethodWithY:(int)Y withX:(int)X { 48*67e74705SXin Li Test1 *cell = [[[Test1 alloc] init] autorelease]; 49*67e74705SXin Li 50*67e74705SXin Li NSString *string1 = [[NSString alloc] initWithFormat:@"test %f %d", 0.0, X+Y]; // expected-warning {{Potential leak}} 51*67e74705SXin Li cell.text = string1; 52*67e74705SXin Li 53*67e74705SXin Li return cell; 54*67e74705SXin Li} 55*67e74705SXin Li 56*67e74705SXin Li@end 57