[cfe-commits] r72799 - /cfe/trunk/test/Analysis/retain-release-gc-only.m
Ted Kremenek
kremenek at apple.com
Wed Jun 3 12:19:12 PDT 2009
Author: kremenek
Date: Wed Jun 3 14:19:06 2009
New Revision: 72799
URL: http://llvm.org/viewvc/llvm-project?rev=72799&view=rev
Log:
Add more retain-checker tests for GC mode when using NSMakeCollectable.
Modified:
cfe/trunk/test/Analysis/retain-release-gc-only.m
Modified: cfe/trunk/test/Analysis/retain-release-gc-only.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release-gc-only.m?rev=72799&r1=72798&r2=72799&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release-gc-only.m (original)
+++ cfe/trunk/test/Analysis/retain-release-gc-only.m Wed Jun 3 14:19:06 2009
@@ -101,6 +101,11 @@
CFTypeRef CFMakeCollectable(CFTypeRef cf) ;
+static __inline__ __attribute__((always_inline)) id NSMakeCollectable(CFTypeRef
+cf) {
+ return cf ? (id)CFMakeCollectable(cf) : ((void*)0);
+}
+
//===----------------------------------------------------------------------===//
// Test cases.
//===----------------------------------------------------------------------===//
@@ -124,6 +129,31 @@
CFRetain(A);
}
+void f3b() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+ CFMakeCollectable(A);
+}
+
+
+void f4() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}}
+ NSMakeCollectable(A);
+ CFRetain(A);
+}
+
+void f4b() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+ NSMakeCollectable(A);
+}
+
+void f5() {
+ id x = [NSMakeCollectable(CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks)) autorelease]; // no-warning
+}
+
+void f5b() {
+ id x = [(id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks) autorelease]; // expected-warning{{leak}}
+}
+
// Test return of non-owned objects in contexts where an owned object
// is expected.
@interface TestReturnNotOwnedWhenExpectedOwned
@@ -133,7 +163,7 @@
@implementation TestReturnNotOwnedWhenExpectedOwned
- (NSString*)newString {
- NSString *s = [NSString stringWithUTF8String:"hello"]; // expected-warning{{Potential leak (when using garbage collection) of an object allocated on line 136 and stored into 's'}}
+ NSString *s = [NSString stringWithUTF8String:"hello"]; // expected-warning{{Potential leak (when using garbage collection) of an object allocated}}
CFRetain(s);
return s;
}
More information about the cfe-commits
mailing list