[cfe-commits] r49772 - in /cfe/trunk/test/Analysis-Apple: CFDate.c CFDate.m
Ted Kremenek
kremenek at apple.com
Tue Apr 15 21:29:22 PDT 2008
Author: kremenek
Date: Tue Apr 15 23:29:21 2008
New Revision: 49772
URL: http://llvm.org/viewvc/llvm-project?rev=49772&view=rev
Log:
Update CF reference count checker test case to illustrate the use of
toll-free bridging.
Added:
cfe/trunk/test/Analysis-Apple/CFDate.m
- copied, changed from r49762, cfe/trunk/test/Analysis-Apple/CFDate.c
Removed:
cfe/trunk/test/Analysis-Apple/CFDate.c
Removed: cfe/trunk/test/Analysis-Apple/CFDate.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis-Apple/CFDate.c?rev=49771&view=auto
==============================================================================
--- cfe/trunk/test/Analysis-Apple/CFDate.c (original)
+++ cfe/trunk/test/Analysis-Apple/CFDate.c (removed)
@@ -1,15 +0,0 @@
-// RUN: clang -checker-cfref -verify %s
-
-#include <CoreFoundation/CFDate.h>
-
-CFAbsoluteTime f1() {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- CFDateRef date = CFDateCreate(NULL, t);
- CFRetain(date);
- CFRelease(date);
- CFDateGetAbsoluteTime(date);
- CFRelease(date);
- t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}}
- return t;
-}
-
Copied: cfe/trunk/test/Analysis-Apple/CFDate.m (from r49762, cfe/trunk/test/Analysis-Apple/CFDate.c)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis-Apple/CFDate.m?p2=cfe/trunk/test/Analysis-Apple/CFDate.m&p1=cfe/trunk/test/Analysis-Apple/CFDate.c&r1=49762&r2=49772&rev=49772&view=diff
==============================================================================
--- cfe/trunk/test/Analysis-Apple/CFDate.c (original)
+++ cfe/trunk/test/Analysis-Apple/CFDate.m Tue Apr 15 23:29:21 2008
@@ -1,15 +1,27 @@
// RUN: clang -checker-cfref -verify %s
#include <CoreFoundation/CFDate.h>
+#include <Foundation/NSDate.h>
CFAbsoluteTime f1() {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(NULL, t);
CFRetain(date);
CFRelease(date);
- CFDateGetAbsoluteTime(date);
+ CFDateGetAbsoluteTime(date); // no-warning
CFRelease(date);
t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}}
return t;
}
+CFAbsoluteTime f2() {
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ CFDateRef date = CFDateCreate(NULL, t);
+ [((NSDate*) date) retain];
+ CFRelease(date);
+ CFDateGetAbsoluteTime(date); // no-warning
+ [((NSDate*) date) release];
+ t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}}
+ return t;
+}
+
More information about the cfe-commits
mailing list