diff options
Diffstat (limited to 'clang/test/Analysis/NSContainers.m')
-rw-r--r-- | clang/test/Analysis/NSContainers.m | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/clang/test/Analysis/NSContainers.m b/clang/test/Analysis/NSContainers.m index 959f367d282..d31c7b1ff03 100644 --- a/clang/test/Analysis/NSContainers.m +++ b/clang/test/Analysis/NSContainers.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg,osx.cocoa.Loops -verify -Wno-objc-root-class %s typedef unsigned long NSUInteger; typedef signed char BOOL; typedef struct _NSZone NSZone; @@ -14,8 +14,6 @@ typedef struct _NSZone NSZone; @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end -@protocol NSFastEnumeration -@end @protocol NSSecureCoding <NSCoding> @required + (BOOL)supportsSecureCoding; @@ -24,11 +22,20 @@ typedef struct _NSZone NSZone; - (id)init; + (id)alloc; @end -@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration> +typedef struct { + unsigned long state; + id *itemsPtr; + unsigned long *mutationsPtr; + unsigned long extra[5]; +} NSFastEnumerationState; +@protocol NSFastEnumeration +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len; +@end + +@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration> - (NSUInteger)count; - (id)objectAtIndex:(NSUInteger)index; - @end @interface NSArray (NSExtendedArray) @@ -243,4 +250,14 @@ void testAssumeNSNullNullReturnsNonNil(NSMutableDictionary *Table, id Object, } } +void testCollectionIsNotEmptyWhenCountIsGreaterThanZero(NSMutableDictionary *D){ + if ([D count] > 0) { // Count is greater than zero. + NSString *s = 0; + for (NSString *key in D) { + s = key; // Loop is always entered. + } + [D removeObjectForKey:s]; // no warning + } +} + |