diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-06-16 21:15:29 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-06-16 21:15:29 +0000 |
commit | d54ae2a8ea965e73e6bb1e09d5ba070fd900b061 (patch) | |
tree | abd7d195a043cb9949962e3a83e4af4f4ad441dd | |
parent | 32dc95e1ae09c740a08c364feaffd8c73821fe15 (diff) |
Move test case "uninit-msg-expr.m" from Analysis-Apple to Analysis (now works on all platforms).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52362 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/Analysis-Apple/uninit-msg-expr.m | 20 | ||||
-rw-r--r-- | test/Analysis/uninit-msg-expr.m | 56 |
2 files changed, 56 insertions, 20 deletions
diff --git a/test/Analysis-Apple/uninit-msg-expr.m b/test/Analysis-Apple/uninit-msg-expr.m deleted file mode 100644 index f054d7ab6c..0000000000 --- a/test/Analysis-Apple/uninit-msg-expr.m +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: clang -checker-simple -verify %s - -#include <Foundation/NSString.h> -#include <Foundation/NSArray.h> - -unsigned f1() { - NSString *aString; - return [aString length]; // expected-warning {{Receiver in message expression is an uninitialized value}} -} - -unsigned f2() { - NSString *aString = nil; - return [aString length]; // no-warning -} - -void f3() { - NSMutableArray *aArray = [NSArray array]; - NSString *aString; - [aArray addObject:aString]; // expected-warning {{Pass-by-value argument in message expression is undefined.}} -} diff --git a/test/Analysis/uninit-msg-expr.m b/test/Analysis/uninit-msg-expr.m new file mode 100644 index 0000000000..10b9837314 --- /dev/null +++ b/test/Analysis/uninit-msg-expr.m @@ -0,0 +1,56 @@ +// RUN: clang -checker-simple -verify %s + +//===----------------------------------------------------------------------===// +// The following code is reduced using delta-debugging from +// Foundation.h (Mac OS X). +// +// It includes the basic definitions for the test cases below. +// Not directly including Foundation.h directly makes this test case +// both svelte and portable to non-Mac platforms. +//===----------------------------------------------------------------------===// + +typedef signed char BOOL; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end +@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end +@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end +@interface NSObject <NSObject> {} @end +@class NSString, NSData; +@class NSString, NSData, NSMutableData, NSMutableDictionary, NSMutableArray; +typedef struct {} NSFastEnumerationState; +@protocol NSFastEnumeration +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; +@end +@class NSData, NSIndexSet, NSString, NSURL; +@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> +- (NSUInteger)count; +@end +@interface NSArray (NSArrayCreation) ++ (id)array; +- (NSUInteger)length; +- (void)addObject:(id)object; +@end +extern NSString * const NSUndoManagerCheckpointNotification; + +//===----------------------------------------------------------------------===// +// Test cases. +//===----------------------------------------------------------------------===// + +unsigned f1() { + NSString *aString; + return [aString length]; // expected-warning {{Receiver in message expression is an uninitialized value}} +} + +unsigned f2() { + NSString *aString = 0; + return [aString length]; // no-warning +} + +void f3() { + NSMutableArray *aArray = [NSArray array]; + NSString *aString; + [aArray addObject:aString]; // expected-warning {{Pass-by-value argument in message expression is undefined.}} +} |