1 // RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.NonNilReturnValue,debug.ExprInspection -verify %s
3 typedef unsigned int NSUInteger;
4 typedef signed char BOOL;
6 @protocol NSObject - (BOOL)isEqual:(id)object; @end
8 @interface NSObject <NSObject> {}
18 @interface NSArray : NSObject
19 - (id)objectAtIndex:(unsigned long)index;
22 @interface NSArray (NSExtendedArray)
23 - (id)objectAtIndexedSubscript:(NSUInteger)idx;
26 @interface NSMutableArray : NSArray
27 - (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
30 @interface NSOrderedSet : NSObject
32 @interface NSOrderedSet (NSOrderedSetCreation)
33 - (id)objectAtIndexedSubscript:(NSUInteger)idx;
36 void clang_analyzer_eval(id);
38 void assumeThatNSArrayObjectAtIndexIsNeverNull(NSArray *A, NSUInteger i) {
39 clang_analyzer_eval([A objectAtIndex: i]); // expected-warning {{TRUE}}
40 id subscriptObj = A[1];
41 clang_analyzer_eval(subscriptObj); // expected-warning {{TRUE}}
44 void assumeThatNSMutableArrayObjectAtIndexIsNeverNull(NSMutableArray *A, NSUInteger i) {
45 clang_analyzer_eval([A objectAtIndex: i]); // expected-warning {{TRUE}}
48 void assumeThatNSArrayObjectAtIndexedSubscriptIsNeverNull(NSOrderedSet *A, NSUInteger i) {
49 clang_analyzer_eval(A[i]); // expected-warning {{TRUE}}