summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-07-22 02:45:48 +0000
committerJohn McCall <rjmccall@apple.com>2011-07-22 02:45:48 +0000
commitd2930c21002ae94d7ef8d8acda5d401cd8f7891a (patch)
treead3b14d0aa7c09d2fb8694f993f8c7eb8962afe1 /clang/test
parentb82bbf40bb5c656d405c54b2c63da79793f09f0f (diff)
downloadbcm5719-llvm-d2930c21002ae94d7ef8d8acda5d401cd8f7891a.tar.gz
bcm5719-llvm-d2930c21002ae94d7ef8d8acda5d401cd8f7891a.zip
In Objective-C, pull arbitrary attributes from overridden
methods, including indirectly overridden methods like those declared in protocols and categories. There are mismatches that we would like to diagnose but aren't yet, but this is fine for now. I looked at approaches that avoided doing this lookup unless we needed it, but the infer-related-result-type checks were doing it anyway, so I left it with the same fast-path check for no previous declartions of that selector. llvm-svn: 135743
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/retain-release.m14
-rw-r--r--clang/test/CodeGenObjC/arc.m26
2 files changed, 40 insertions, 0 deletions
diff --git a/clang/test/Analysis/retain-release.m b/clang/test/Analysis/retain-release.m
index 71ae756cf04..457c9023c40 100644
--- a/clang/test/Analysis/retain-release.m
+++ b/clang/test/Analysis/retain-release.m
@@ -1540,3 +1540,17 @@ CFArrayRef camel_copymachine() {
return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
}
+// rdar://problem/8024350
+@protocol F18P
+- (id) clone;
+@end
+@interface F18 : NSObject<F18P> @end
+@interface F18(Cat)
+- (id) clone NS_RETURNS_RETAINED;
+@end
+
+@implementation F18
+- (id) clone {
+ return [F18 alloc];
+}
+@end
diff --git a/clang/test/CodeGenObjC/arc.m b/clang/test/CodeGenObjC/arc.m
index 407b3eb7716..f6bd4341959 100644
--- a/clang/test/CodeGenObjC/arc.m
+++ b/clang/test/CodeGenObjC/arc.m
@@ -1552,3 +1552,29 @@ void test54(int first, ...) {
// CHECK: define internal void @"\01-[Test55(Category) dealloc]"(
// CHECK-NOT: ret
// CHECK: call void bitcast (i8* ({{%.*}}*, i8*, ...)* @objc_msgSendSuper2 to void ({{%.*}}*, i8*)*)(
+
+// rdar://problem/8024350
+@protocol Test56Protocol
++ (id) make __attribute__((ns_returns_retained));
+@end
+@interface Test56<Test56Protocol> @end
+@implementation Test56
+// CHECK: define internal i8* @"\01+[Test56 make]"(
++ (id) make {
+ extern id test56_helper(void);
+ // CHECK: [[T0:%.*]] = call i8* @test56_helper()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: ret i8* [[T1]]
+ return test56_helper();
+}
+@end
+void test56_test(void) {
+ id x = [Test56 make];
+ // CHECK: define void @test56_test()
+ // CHECK: [[X:%.*]] = alloca i8*, align 8
+ // CHECK: [[T0:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(
+ // CHECK-NEXT: store i8* [[T0]], i8** [[X]]
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: ret void
+}
OpenPOWER on IntegriCloud