From: Ted Kremenek Date: Mon, 16 Jun 2008 18:46:17 +0000 (+0000) Subject: Move CFDateGC.m test case from Analysis-Apple to Analysis (it now runs on all platforms). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88739bff1d856e7087f9b60bd7c2ec292856ee6b;p=clang Move CFDateGC.m test case from Analysis-Apple to Analysis (it now runs on all platforms). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52344 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis-Apple/CFDateGC.m b/test/Analysis-Apple/CFDateGC.m deleted file mode 100644 index 9511066fe7..0000000000 --- a/test/Analysis-Apple/CFDateGC.m +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: clang -checker-cfref -verify -fobjc-gc %s - -#include -#include -#include - -CFAbsoluteTime f1() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(NULL, t); - CFRetain(date); - [NSMakeCollectable(date) release]; - CFDateGetAbsoluteTime(date); // no-warning - CFRelease(date); - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}} - return t; -} - diff --git a/test/Analysis/CFDateGC.m b/test/Analysis/CFDateGC.m new file mode 100644 index 0000000000..3d8fce6a7c --- /dev/null +++ b/test/Analysis/CFDateGC.m @@ -0,0 +1,39 @@ +// RUN: clang -checker-cfref -verify -fobjc-gc %s + +//===----------------------------------------------------------------------===// +// The following code is reduced using delta-debugging from +// Foundation.h and CoreFoundation.h (Mac OS X). +// +// It includes the basic definitions for the test cases below. +// Not directly including [Core]Foundation.h directly makes this test case +// both svelt and portable to non-Mac platforms. +//===----------------------------------------------------------------------===// + +typedef const void * CFTypeRef; +typedef const struct __CFAllocator * CFAllocatorRef; +typedef double CFTimeInterval; +typedef CFTimeInterval CFAbsoluteTime; +typedef const struct __CFDate * CFDateRef; +extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at); +typedef signed char BOOL; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; +static __inline__ __attribute__((always_inline)) id NSMakeCollectable(CFTypeRef cf) {} +@protocol NSObject - (BOOL)isEqual:(id)object; - (oneway void)release; @end +extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); + +//===----------------------------------------------------------------------===// +// Test cases. +//===----------------------------------------------------------------------===// + +CFAbsoluteTime f1() { + CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); + CFDateRef date = CFDateCreate(0, t); + CFRetain(date); + [NSMakeCollectable(date) release]; + CFDateGetAbsoluteTime(date); // no-warning + CFRelease(date); + t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}} + return t; +} +