blob: 3bceca0e6c376ea3e77683fa04b74116d269d001 [file] [log] [blame]
Daniel Dunbard4270232009-01-20 23:17:32 +00001// RUN: clang -analyze -checker-simple -verify %s
Ted Kremenekd54ae2a2008-06-16 21:15:29 +00002
3//===----------------------------------------------------------------------===//
4// The following code is reduced using delta-debugging from
5// Foundation.h (Mac OS X).
6//
7// It includes the basic definitions for the test cases below.
8// Not directly including Foundation.h directly makes this test case
9// both svelte and portable to non-Mac platforms.
10//===----------------------------------------------------------------------===//
11
12typedef signed char BOOL;
13typedef unsigned int NSUInteger;
14typedef struct _NSZone NSZone;
15@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
16@protocol NSObject - (BOOL)isEqual:(id)object; @end
17@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
18@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
19@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
20@interface NSObject <NSObject> {} @end
21@class NSString, NSData;
22@class NSString, NSData, NSMutableData, NSMutableDictionary, NSMutableArray;
23typedef struct {} NSFastEnumerationState;
24@protocol NSFastEnumeration
25- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
26@end
27@class NSData, NSIndexSet, NSString, NSURL;
28@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
29- (NSUInteger)count;
30@end
31@interface NSArray (NSArrayCreation)
32+ (id)array;
33- (NSUInteger)length;
34- (void)addObject:(id)object;
35@end
36extern NSString * const NSUndoManagerCheckpointNotification;
37
38//===----------------------------------------------------------------------===//
39// Test cases.
40//===----------------------------------------------------------------------===//
41
42unsigned f1() {
43 NSString *aString;
44 return [aString length]; // expected-warning {{Receiver in message expression is an uninitialized value}}
45}
46
47unsigned f2() {
48 NSString *aString = 0;
49 return [aString length]; // no-warning
50}
51
52void f3() {
53 NSMutableArray *aArray = [NSArray array];
54 NSString *aString;
55 [aArray addObject:aString]; // expected-warning {{Pass-by-value argument in message expression is undefined.}}
56}