1// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify %s 2 3typedef signed char BOOL; 4typedef long NSInteger; 5typedef unsigned long NSUInteger; 6@interface NSString @end 7@interface NSString (NSStringExtensionMethods) 8+ (id)stringWithUTF8String:(const char *)nullTerminatedCString; 9@end 10 11@interface NSNumber 12+ (NSNumber *)numberWithChar:(char)value; 13+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; 14+ (NSNumber *)numberWithShort:(short)value; 15+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; 16+ (NSNumber *)numberWithInt:(int)value; 17+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; 18+ (NSNumber *)numberWithLong:(long)value; 19+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; 20+ (NSNumber *)numberWithLongLong:(long long)value; 21+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; 22+ (NSNumber *)numberWithFloat:(float)value; 23+ (NSNumber *)numberWithDouble:(double)value; 24+ (NSNumber *)numberWithBool:(BOOL)value; 25+ (NSNumber *)numberWithInteger:(NSInteger)value ; 26+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ; 27@end 28 29 30extern char *strdup(const char *str); 31 32id constant_string() { 33 return @("boxed constant string."); 34} 35 36id dynamic_string() { 37 return @(strdup("boxed dynamic string")); // expected-warning{{Memory is never released; potential leak}} 38} 39 40id const_char_pointer(int *x) { 41 if (x) 42 return @(3); 43 return @(*x); // expected-warning {{Dereference of null pointer (loaded from variable 'x')}} 44}