]> granicus.if.org Git - clang/commitdiff
Add back test cases for ns_returns_retained and cf_returns_retained.
authorTed Kremenek <kremenek@apple.com>
Sat, 9 May 2009 03:10:32 +0000 (03:10 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 9 May 2009 03:10:32 +0000 (03:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71312 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/retain-release-gc-only.m
test/Analysis/retain-release.m

index f83c7e115df6eb3a128c816a81a5cb603991438f..f9e00d3eab8fd32485311bc340e7033519cb728b 100644 (file)
@@ -124,3 +124,20 @@ void f3() {
   CFRetain(A);
 }
 
+//===----------------------------------------------------------------------===//
+// Tests of ownership attributes.
+//===----------------------------------------------------------------------===//
+
+@interface TestOwnershipAttr : NSObject
+- (NSString*) returnsAnOwnedString __attribute__((ns_returns_retained));
+- (NSString*) returnsAnOwnedCFString  __attribute__((cf_returns_retained));
+@end
+
+void test_attr_1(TestOwnershipAttr *X) {
+  NSString *str = [X returnsAnOwnedString]; // no-warning
+}
+
+void test_attr_1b(TestOwnershipAttr *X) {
+  NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}}
+}
+
index 49fd98b3b7ed132dfc3a7ab1981dc064cf562a32..acc469a7b7733205df740874f1bf091ded7ce677 100644 (file)
@@ -475,3 +475,20 @@ void rdar6704930(unsigned char *s, unsigned int length) {
 }
 @end
 
+//===----------------------------------------------------------------------===//
+// Tests of ownership attributes.
+//===----------------------------------------------------------------------===//
+
+@interface TestOwnershipAttr : NSObject
+- (NSString*) returnsAnOwnedString  __attribute__((ns_returns_retained));
+- (NSString*) returnsAnOwnedCFString  __attribute__((cf_returns_retained));
+@end
+
+void test_attr_1(TestOwnershipAttr *X) {
+  NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}}
+}
+
+void test_attr_1b(TestOwnershipAttr *X) {
+  NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}}
+}
+