summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenObjC
diff options
context:
space:
mode:
authorErik Pilkington <erik.pilkington@gmail.com>2019-05-15 20:15:01 +0000
committerErik Pilkington <erik.pilkington@gmail.com>2019-05-15 20:15:01 +0000
commitf6c645f9fd93190be479fff697cff9a45c208bbf (patch)
tree5ec7aa7b4b0999d408986831df2702f9e31d9cba /clang/test/CodeGenObjC
parent11b515ac0af15e0646bde5a7bf2b0f8867bfbff6 (diff)
downloadbcm5719-llvm-f6c645f9fd93190be479fff697cff9a45c208bbf.tar.gz
bcm5719-llvm-f6c645f9fd93190be479fff697cff9a45c208bbf.zip
[CodeGenObjC] invoke objc_autorelease, objc_retain when necessary
Any of these methods can be overridden, so we need to invoke these functions. Differential revision: https://reviews.llvm.org/D61957 llvm-svn: 360802
Diffstat (limited to 'clang/test/CodeGenObjC')
-rw-r--r--clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m45
-rw-r--r--clang/test/CodeGenObjC/objc-alloc-init.m15
2 files changed, 54 insertions, 6 deletions
diff --git a/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m b/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
index d1a96249324..6a4edfd0979 100644
--- a/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ b/clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -177,8 +177,8 @@ float test_cannot_message_return_float(C *c) {
@class Ety;
-// CHECK-LABEL: define {{.*}}void @testException
-void testException(NSObject *a) {
+// CHECK-LABEL: define {{.*}}void @testException_release
+void testException_release(NSObject *a) {
// MSGS: {{invoke.*@objc_msgSend}}
// CALLS: invoke{{.*}}void @objc_release(i8* %
@try {
@@ -186,3 +186,44 @@ void testException(NSObject *a) {
} @catch (Ety *e) {
}
}
+
+// CHECK-LABEL: define {{.*}}void @testException_autorelease
+void testException_autorelease(NSObject *a) {
+ @try {
+ // MSGS: {{invoke.*@objc_msgSend}}
+ // CALLS: invoke{{.*}}objc_autorelease(i8* %
+ [a autorelease];
+ } @catch (Ety *e) {
+ }
+}
+
+// CHECK-LABEL: define {{.*}}void @testException_retain
+void testException_retain(NSObject *a) {
+ @try {
+ // MSGS: {{invoke.*@objc_msgSend}}
+ // CALLS: invoke{{.*}}@objc_retain(i8* %
+ [a retain];
+ } @catch (Ety *e) {
+ }
+}
+
+
+// CHECK-LABEL: define {{.*}}void @testException_alloc(
+void testException_alloc() {
+ @try {
+ // MSGS: {{invoke.*@objc_msgSend}}
+ // CALLS: invoke{{.*}}@objc_alloc(i8* %
+ [A alloc];
+ } @catch (Ety *e) {
+ }
+}
+
+// CHECK-LABEL: define {{.*}}void @testException_allocWithZone
+void testException_allocWithZone() {
+ @try {
+ // MSGS: {{invoke.*@objc_msgSend}}
+ // CALLS: invoke{{.*}}@objc_allocWithZone(i8* %
+ [A allocWithZone:nil];
+ } @catch (Ety *e) {
+ }
+}
diff --git a/clang/test/CodeGenObjC/objc-alloc-init.m b/clang/test/CodeGenObjC/objc-alloc-init.m
index a55a9835c8a..08a383d59f6 100644
--- a/clang/test/CodeGenObjC/objc-alloc-init.m
+++ b/clang/test/CodeGenObjC/objc-alloc-init.m
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -fobjc-runtime=macosx-10.14.4 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
-// RUN: %clang_cc1 %s -fobjc-runtime=macosx-10.14.3 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
-// RUN: %clang_cc1 %s -fobjc-runtime=ios-12.2 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
-// RUN: %clang_cc1 %s -fobjc-runtime=ios-12.1 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=macosx-10.14.4 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=macosx-10.14.3 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=ios-12.2 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=ios-12.1 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
@interface X
+(X *)alloc;
@@ -12,6 +12,13 @@ void f() {
[[X alloc] init];
// OPTIMIZED: call i8* @objc_alloc_init(
// NOT_OPTIMIZED: call i8* @objc_alloc(
+
+ @try {
+ [[X alloc] init];
+ } @catch (X *x) {
+ }
+ // OPTIMIZED: invoke i8* @objc_alloc_init(
+ // NOT_OPTIMIZED: invoke i8* @objc_alloc(
}
@interface Y : X
OpenPOWER on IntegriCloud