[cfe-commits] r156660 - /cfe/trunk/test/Analysis/objc-boxing.m
Anna Zaks
ganna at apple.com
Fri May 11 18:08:54 PDT 2012
On May 11, 2012, at 5:39 PM, Jordy Rose wrote:
> Do we need a test for boxed expressions and retain counts?
Can you give an example (or just feel free to commit it)?
> I see there's already a test for collection literals, but not integer literals or arbitrary boxed expressions.
>
I have:
>> + return @(3);
>> + return @(*x);
Anna.
> Jordy
>
>
> On May 11, 2012, at 19:15, Anna Zaks wrote:
>
>> Author: zaks
>> Date: Fri May 11 18:15:16 2012
>> New Revision: 156660
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=156660&view=rev
>> Log:
>> [analyzer] Test objC boxing.
>>
>> Added:
>> cfe/trunk/test/Analysis/objc-boxing.m
>>
>> Added: cfe/trunk/test/Analysis/objc-boxing.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/objc-boxing.m?rev=156660&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/Analysis/objc-boxing.m (added)
>> +++ cfe/trunk/test/Analysis/objc-boxing.m Fri May 11 18:15:16 2012
>> @@ -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;
>> + at interface NSString @end
>> + at interface NSString (NSStringExtensionMethods)
>> ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
>> + at end
>> +
>> + at 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 ;
>> + at 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
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list