From 2659aeb5e51fe27d24bbffad0d1851b39fed5e43 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 3 Jun 2009 21:11:25 +0000 Subject: Import Clang, at r72805. --- test/Analysis/retain-release-gc-only.m | 32 +++++++++++++++++++++++++++++++- test/CodeGen/always_inline.c | 4 ++-- test/CodeGen/cast-to-union.c | 1 + test/CodeGenObjC/objc2-weak-assign.m | 22 ++++++++++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 test/CodeGenObjC/objc2-weak-assign.m (limited to 'test') diff --git a/test/Analysis/retain-release-gc-only.m b/test/Analysis/retain-release-gc-only.m index 70ad54f8aa4a8..cc4a40db092fb 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 d159bd2233e42..cb32e3b621810 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 03aee3e30c4fe..6098bcc5a07ce 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 0000000000000..a3740b207e85d --- /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; +} + -- cgit v1.3