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=EITHER
2// 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
3// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=ios-12.2 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
4// 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
5
6@interface X
7+(X *)alloc;
8-(X *)init;
9@end
10
11void f() {
12  [[X alloc] init];
13  // OPTIMIZED: call i8* @objc_alloc_init(
14  // NOT_OPTIMIZED: call i8* @objc_alloc(
15
16  @try {
17    [[X alloc] init];
18  } @catch (X *x) {
19  }
20  // OPTIMIZED: invoke i8* @objc_alloc_init(
21  // NOT_OPTIMIZED: invoke i8* @objc_alloc(
22}
23
24@interface Y : X
25+(void)meth;
26@end
27
28@implementation Y
29+(void)meth {
30  [[self alloc] init];
31  // EITHER-NOT: call i8* @objc_alloc
32  // EITHER: call {{.*}} @objc_msgSend
33  // EITHER: call {{.*}} @objc_msgSend
34}
35@end
36
37// rdar://48247290
38@interface Base
39-(instancetype)init;
40@end
41
42@interface Derived : Base
43@end
44@implementation Derived
45-(void)meth {
46  [super init];
47}
48@end
49