diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-06-16 18:34:22 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-06-16 18:34:22 +0000 |
commit | 7056bb1f212bccc2cc7feb6e2042c56fab371905 (patch) | |
tree | 4846f5eb5e194eee562f4ec0ea9197f85eab8801 /clang | |
parent | 9995302b02834defb9d37b3d0294bc43fb05fc85 (diff) | |
download | bcm5719-llvm-7056bb1f212bccc2cc7feb6e2042c56fab371905.tar.gz bcm5719-llvm-7056bb1f212bccc2cc7feb6e2042c56fab371905.zip |
Moved CFDate.m from test/Analysis-Apple to test/Analysis, and added the necessary declarations from Foundation.h to CFDate.m so that the test case can be exercised on all platforms.
llvm-svn: 52343
Diffstat (limited to 'clang')
-rw-r--r-- | clang/test/Analysis/CFDate.m (renamed from clang/test/Analysis-Apple/CFDate.m) | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/clang/test/Analysis-Apple/CFDate.m b/clang/test/Analysis/CFDate.m index 64894da6c56..4deaf4a2b43 100644 --- a/clang/test/Analysis-Apple/CFDate.m +++ b/clang/test/Analysis/CFDate.m @@ -1,13 +1,40 @@ // RUN: clang -checker-cfref -verify %s -#include <CoreFoundation/CFDate.h> -#include <Foundation/NSDate.h> -#include <Foundation/NSCalendarDate.h> -#include <Foundation/NSString.h> +//===----------------------------------------------------------------------===// +// 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 including Foundation.h directly makes this test case both svelt and +// portable to non-Mac platforms. +//===----------------------------------------------------------------------===// + +typedef const struct __CFAllocator * CFAllocatorRef; +typedef double CFTimeInterval; +typedef CFTimeInterval CFAbsoluteTime; +typedef const struct __CFDate * CFDateRef; +extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at); +typedef struct objc_object {} *id; +typedef signed char BOOL; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; +@protocol NSObject - (BOOL)isEqual:(id)object; - (id)retain; - (oneway void)release; @end +@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end +@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end +@interface NSObject <NSObject> {} @end +extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +typedef double NSTimeInterval; +@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate; @end +@class NSString, NSArray, NSTimeZone; + +//===----------------------------------------------------------------------===// +// Test cases. +//===----------------------------------------------------------------------===// CFAbsoluteTime f1() { CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(NULL, t); + CFDateRef date = CFDateCreate(0, t); CFRetain(date); CFRelease(date); CFDateGetAbsoluteTime(date); // no-warning @@ -18,7 +45,7 @@ CFAbsoluteTime f1() { CFAbsoluteTime f2() { CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(NULL, t); + CFDateRef date = CFDateCreate(0, t); [((NSDate*) date) retain]; CFRelease(date); CFDateGetAbsoluteTime(date); // no-warning @@ -35,7 +62,7 @@ NSDate* global_x; CFAbsoluteTime f3() { CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(NULL, t); + CFDateRef date = CFDateCreate(0, t); [((NSDate*) date) retain]; CFRelease(date); CFDateGetAbsoluteTime(date); // no-warning @@ -56,7 +83,7 @@ CFAbsoluteTime f4() { struct foo x; CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(NULL, t); + CFDateRef date = CFDateCreate(0, t); [((NSDate*) date) retain]; CFRelease(date); CFDateGetAbsoluteTime(date); // no-warning @@ -70,7 +97,7 @@ CFAbsoluteTime f4() { CFAbsoluteTime f5(int x) { CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(NULL, t); + CFDateRef date = CFDateCreate(0, t); if (x) CFRelease(date); @@ -81,7 +108,7 @@ CFAbsoluteTime f5(int x) { // Test a leak involving the return. CFDateRef f6(int x) { - CFDateRef date = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent()); + CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); CFRetain(date); return date; // expected-warning{{leak}} } @@ -89,9 +116,9 @@ CFDateRef f6(int x) { // Test a leak involving an overwrite. CFDateRef f7() { - CFDateRef date = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent()); + CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); CFRetain(date); //expected-warning{{leak}} - date = CFDateCreate(NULL, CFAbsoluteTimeGetCurrent()); + date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); return date; } @@ -106,4 +133,3 @@ CFDateRef f8() { return date; // expected-warning{{leak}} } - |