Clang Project

clang_source_code/test/CodeGenObjC/objc-alloc-init.m
1// RUN: %clang_cc1 %s -fobjc-runtime=macosx-10.14.4 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
2// RUN: %clang_cc1 %s -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-runtime=ios-12.2 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
4// RUN: %clang_cc1 %s -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
17@interface Y : X
18+(void)meth;
19@end
20
21@implementation Y
22+(void)meth {
23  [[self alloc] init];
24  // EITHER-NOT: call i8* @objc_alloc
25  // EITHER: call {{.*}} @objc_msgSend
26  // EITHER: call {{.*}} @objc_msgSend
27}
28@end
29
30// rdar://48247290
31@interface Base
32-(instancetype)init;
33@end
34
35@interface Derived : Base
36@end
37@implementation Derived
38-(void)meth {
39  [super init];
40}
41@end
42