63 lines · plain
1// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=macosx-10.14.4 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER2// 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=EITHER3// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=ios-12.2 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER4// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=ios-12.1 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER5 6@interface X7+(X *)alloc;8-(X *)init;9@end10 11void f(void) {12 [[X alloc] init];13 // OPTIMIZED: call ptr @objc_alloc_init(14 // NOT_OPTIMIZED: call ptr @objc_alloc(15 16 @try {17 [[X alloc] init];18 } @catch (X *x) {19 }20 // OPTIMIZED: invoke ptr @objc_alloc_init(21 // NOT_OPTIMIZED: invoke ptr @objc_alloc(22}23 24@interface Y : X25+(Class)class;26+(void)meth;27-(void)instanceMeth;28@end29 30@implementation Y31+(Class)class {32 return self;33}34+(void)meth {35 [[self alloc] init];36 // OPTIMIZED: call ptr @objc_alloc_init(37 // NOT_OPTIMIZED: call ptr @objc_alloc(38}39+ (void)meth2 {40 [[[self class] alloc] init];41 // OPTIMIZED: call ptr @objc_alloc_init(42 // NOT_OPTIMIZED: call ptr @objc_alloc(43}44-(void)instanceMeth {45 // EITHER-NOT: call ptr @objc_alloc46 // EITHER: call {{.*}} @objc_msgSend47 // EITHER: call {{.*}} @objc_msgSend48 [[(id)self alloc] init];49}50@end51 52@interface Base53-(instancetype)init;54@end55 56@interface Derived : Base57@end58@implementation Derived59-(void)meth {60 [super init];61}62@end63