diff options
author | ed <ed@FreeBSD.org> | 2009-06-03 21:11:25 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-03 21:11:25 +0000 |
commit | 9e262ca77e924f9d84a864b031a1b931d03c5e38 (patch) | |
tree | f0e24d4185187f7d15274dee4bc53908e30f5b76 /test | |
parent | 48ecc7affef226b2bac1e08bdfdc059306a1734c (diff) | |
download | FreeBSD-src-9e262ca77e924f9d84a864b031a1b931d03c5e38.zip FreeBSD-src-9e262ca77e924f9d84a864b031a1b931d03c5e38.tar.gz |
Import Clang, at r72805.
Diffstat (limited to 'test')
-rw-r--r-- | test/Analysis/retain-release-gc-only.m | 32 | ||||
-rw-r--r-- | test/CodeGen/always_inline.c | 4 | ||||
-rw-r--r-- | test/CodeGen/cast-to-union.c | 1 | ||||
-rw-r--r-- | test/CodeGenObjC/objc2-weak-assign.m | 22 |
4 files changed, 56 insertions, 3 deletions
diff --git a/test/Analysis/retain-release-gc-only.m b/test/Analysis/retain-release-gc-only.m index 70ad54f..cc4a40d 100644 --- a/test/Analysis/retain-release-gc-only.m +++ b/test/Analysis/retain-release-gc-only.m @@ -101,6 +101,11 @@ extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn stat 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 @@ void f3() { 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 @@ void f3() { @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; } diff --git a/test/CodeGen/always_inline.c b/test/CodeGen/always_inline.c index d159bd22..cb32e3b 100644 --- a/test/CodeGen/always_inline.c +++ b/test/CodeGen/always_inline.c @@ -1,6 +1,6 @@ -// RUN: clang-cc -emit-llvm -o %t %s && +// RUN: clang -emit-llvm -S -o %t %s && // RUN: grep '@f0' %t | count 0 && -// RUN: clang-cc -disable-llvm-optzns -emit-llvm -o %t %s && +// RUN: clang -mllvm -disable-llvm-optzns -emit-llvm -S -o %t %s && // RUN: grep '@f0' %t | count 2 //static int f0() { diff --git a/test/CodeGen/cast-to-union.c b/test/CodeGen/cast-to-union.c index 03aee3e..6098bcc 100644 --- a/test/CodeGen/cast-to-union.c +++ b/test/CodeGen/cast-to-union.c @@ -7,6 +7,7 @@ union u { int i; double d; }; void foo() { union u ola = (union u) 351; + union u olb = (union u) 1.0; } union u w = (union u)2; diff --git a/test/CodeGenObjC/objc2-weak-assign.m b/test/CodeGenObjC/objc2-weak-assign.m new file mode 100644 index 0000000..a3740b2 --- /dev/null +++ b/test/CodeGenObjC/objc2-weak-assign.m @@ -0,0 +1,22 @@ +// RUN: clang-cc -triple x86_64-apple-darwin9 -fobjc-gc -emit-llvm -o %t %s && +// RUN: grep -e "objc_assign_weak" %t | grep -e "call" | count 6 + +__weak id* x; +id* __weak y; +id* __weak* z; + +__weak id* a1[20]; +id* __weak a2[30]; +id** __weak a3[40]; + +int main() +{ + *x = 0; + *y = 0; + **z = 0; + + a1[3] = 0; + a2[3] = 0; + a3[3][4] = 0; +} + |