diff options
| author | Anna Zaks <ganna@apple.com> | 2012-05-11 23:15:16 +0000 |
|---|---|---|
| committer | Anna Zaks <ganna@apple.com> | 2012-05-11 23:15:16 +0000 |
| commit | 5983aa67d5ac55f60f13605c9d4d3a311ce4c833 (patch) | |
| tree | 27ce62957c1695d116f9cba6d0e7766631a1685b | |
| parent | 2d10fdd4ec48f751bdb1a81c2e0142daa1f6a2c0 (diff) | |
| download | bcm5719-llvm-5983aa67d5ac55f60f13605c9d4d3a311ce4c833.tar.gz bcm5719-llvm-5983aa67d5ac55f60f13605c9d4d3a311ce4c833.zip | |
[analyzer] Test objC boxing.
llvm-svn: 156660
| -rw-r--r-- | clang/test/Analysis/objc-boxing.m | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/clang/test/Analysis/objc-boxing.m b/clang/test/Analysis/objc-boxing.m new file mode 100644 index 00000000000..16915788d63 --- /dev/null +++ b/clang/test/Analysis/objc-boxing.m @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify %s + +typedef signed char BOOL; +typedef long NSInteger; +typedef unsigned long NSUInteger; +@interface NSString @end +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end + +@interface NSNumber ++ (NSNumber *)numberWithChar:(char)value; ++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; ++ (NSNumber *)numberWithShort:(short)value; ++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; ++ (NSNumber *)numberWithInt:(int)value; ++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; ++ (NSNumber *)numberWithLong:(long)value; ++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; ++ (NSNumber *)numberWithLongLong:(long long)value; ++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; ++ (NSNumber *)numberWithFloat:(float)value; ++ (NSNumber *)numberWithDouble:(double)value; ++ (NSNumber *)numberWithBool:(BOOL)value; ++ (NSNumber *)numberWithInteger:(NSInteger)value ; ++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ; +@end + + +extern char *strdup(const char *str); + +id constant_string() { + return @("boxed constant string."); +} + +id dynamic_string() { + return @(strdup("boxed dynamic string")); // expected-warning{{Memory is never released; potential leak}} +} + +id const_char_pointer(int *x) { + if (x) + return @(3); + return @(*x); // expected-warning {{Dereference of null pointer (loaded from variable 'x')}} +}
\ No newline at end of file |

