[cfe-commits] r52344 - in /cfe/trunk/test: Analysis-Apple/CFDateGC.m Analysis/CFDateGC.m
Ted Kremenek
kremenek at apple.com
Mon Jun 16 11:46:17 PDT 2008
Author: kremenek
Date: Mon Jun 16 13:46:17 2008
New Revision: 52344
URL: http://llvm.org/viewvc/llvm-project?rev=52344&view=rev
Log:
Move CFDateGC.m test case from Analysis-Apple to Analysis (it now runs on all platforms).
Added:
cfe/trunk/test/Analysis/CFDateGC.m
Removed:
cfe/trunk/test/Analysis-Apple/CFDateGC.m
Removed: cfe/trunk/test/Analysis-Apple/CFDateGC.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis-Apple/CFDateGC.m?rev=52343&view=auto
==============================================================================
--- cfe/trunk/test/Analysis-Apple/CFDateGC.m (original)
+++ cfe/trunk/test/Analysis-Apple/CFDateGC.m (removed)
@@ -1,17 +0,0 @@
-// RUN: clang -checker-cfref -verify -fobjc-gc %s
-
-#include <CoreFoundation/CFDate.h>
-#include <Foundation/NSDate.h>
-#include <Foundation/NSZone.h>
-
-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;
-}
-
Added: cfe/trunk/test/Analysis/CFDateGC.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CFDateGC.m?rev=52344&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/CFDateGC.m (added)
+++ cfe/trunk/test/Analysis/CFDateGC.m Mon Jun 16 13:46:17 2008
@@ -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) {}
+ at 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;
+}
+
More information about the cfe-commits
mailing list