annotate clang/test/CodeGenObjC/parameterized_classes.m @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1f2b6ac9f198
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fobjc-arc -emit-llvm -o - %s | FileCheck %s
150
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // Parameterized classes have no effect on code generation; this test
anatofuz
parents:
diff changeset
4 // mainly verifies that CodeGen doesn't assert when substituted types
anatofuz
parents:
diff changeset
5 // in uses of methods don't line up exactly with the parameterized
anatofuz
parents:
diff changeset
6 // types in the method declarations due to type erasure. "Not crash"
anatofuz
parents:
diff changeset
7 // is the only interesting criteria here.
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 @protocol NSObject
anatofuz
parents:
diff changeset
10 @end
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 @protocol NSCopying
anatofuz
parents:
diff changeset
13 @end
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 __attribute__((objc_root_class))
anatofuz
parents:
diff changeset
16 @interface NSObject <NSObject>
anatofuz
parents:
diff changeset
17 @end
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 @interface NSString : NSObject <NSCopying>
anatofuz
parents:
diff changeset
20 @end
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 @interface NSMutableArray<T> : NSObject <NSCopying>
anatofuz
parents:
diff changeset
23 @property (copy,nonatomic) T firstObject;
anatofuz
parents:
diff changeset
24 - (void)addObject:(T)object;
anatofuz
parents:
diff changeset
25 - (void)sortWithFunction:(int (*)(T, T))function;
anatofuz
parents:
diff changeset
26 - (void)getObjects:(T __strong *)objects length:(unsigned*)length;
anatofuz
parents:
diff changeset
27 - (T)objectAtIndexedSubscript:(unsigned)index;
anatofuz
parents:
diff changeset
28 - (void)setObject:(T)object atIndexedSubscript:(unsigned)index;
anatofuz
parents:
diff changeset
29 @end
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 NSString *getFirstObjectProp(NSMutableArray<NSString *> *array) {
anatofuz
parents:
diff changeset
32 return array.firstObject;
anatofuz
parents:
diff changeset
33 }
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 NSString *getFirstObjectMethod(NSMutableArray<NSString *> *array) {
anatofuz
parents:
diff changeset
36 return [array firstObject];
anatofuz
parents:
diff changeset
37 }
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 void addObject(NSMutableArray<NSString *> *array, NSString *obj) {
anatofuz
parents:
diff changeset
40 [array addObject: obj];
anatofuz
parents:
diff changeset
41 }
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 int compareStrings(NSString *x, NSString *y) { return 0; }
anatofuz
parents:
diff changeset
44 int compareBlocks(NSString * (^x)(NSString *),
anatofuz
parents:
diff changeset
45 NSString * (^y)(NSString *)) { return 0; }
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 void sortTest(NSMutableArray<NSString *> *array,
anatofuz
parents:
diff changeset
48 NSMutableArray<NSString * (^)(NSString *)> *array2) {
anatofuz
parents:
diff changeset
49 [array sortWithFunction: &compareStrings];
anatofuz
parents:
diff changeset
50 [array2 sortWithFunction: &compareBlocks];
anatofuz
parents:
diff changeset
51 }
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 void getObjectsTest(NSMutableArray<NSString *> *array) {
anatofuz
parents:
diff changeset
54 NSString * __strong *objects;
anatofuz
parents:
diff changeset
55 unsigned length;
anatofuz
parents:
diff changeset
56 [array getObjects: objects length: &length];
anatofuz
parents:
diff changeset
57 }
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 void printMe(NSString *name) { }
anatofuz
parents:
diff changeset
60
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
61 // CHECK-LABEL: define{{.*}} void @blockTest
150
anatofuz
parents:
diff changeset
62 void blockTest(NSMutableArray<void (^)(void)> *array, NSString *name) {
anatofuz
parents:
diff changeset
63 // CHECK-NOT: ret void
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
64 // CHECK: call ptr @llvm.objc.retainBlock
150
anatofuz
parents:
diff changeset
65 [array addObject: ^ { printMe(name); }];
anatofuz
parents:
diff changeset
66 // CHECK-NOT: ret void
anatofuz
parents:
diff changeset
67 array[0] = ^ { printMe(name); };
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
68 // CHECK: call ptr @llvm.objc.retainBlock
150
anatofuz
parents:
diff changeset
69 // CHECK: ret void
anatofuz
parents:
diff changeset
70 }
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 // CHECK-LABEL: define internal void @"\01-[Derived setDest:]
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
73 // CHECK: %[[SELFADDR:.*]] = alloca ptr
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
74 // CHECK: %[[AADDR:a.addr]] = alloca ptr
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
75 // CHECK: %[[V2:.*]] = load ptr, ptr %[[AADDR]]
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
76 // CHECK: %[[V3:.*]] = load ptr, ptr %[[SELFADDR]]
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
77 // CHECK: %[[IVAR:.*]] = load i64, ptr @"OBJC_IVAR_$_Base._destination"
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
78 // CHECK: %[[ADDPTR:.*]] = getelementptr inbounds i8, ptr %[[V3]], i64 %[[IVAR]]
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
79 // CHECK: call void @llvm.objc.storeStrong(ptr %[[ADDPTR]], ptr %[[V2]])
150
anatofuz
parents:
diff changeset
80
anatofuz
parents:
diff changeset
81 @interface Base<DestType> : NSObject {
anatofuz
parents:
diff changeset
82 DestType _destination;
anatofuz
parents:
diff changeset
83 }
anatofuz
parents:
diff changeset
84 @end
anatofuz
parents:
diff changeset
85
anatofuz
parents:
diff changeset
86 @interface Derived : Base<NSObject *>
anatofuz
parents:
diff changeset
87 - (void)setDest:(NSObject *)a;
anatofuz
parents:
diff changeset
88 @end
anatofuz
parents:
diff changeset
89
anatofuz
parents:
diff changeset
90 @implementation Derived
anatofuz
parents:
diff changeset
91 - (void)setDest:(NSObject *)a {
anatofuz
parents:
diff changeset
92 _destination = a;
anatofuz
parents:
diff changeset
93 }
anatofuz
parents:
diff changeset
94 @end
anatofuz
parents:
diff changeset
95
anatofuz
parents:
diff changeset
96 // CHECK-LABEL: define internal void @"\01-[C0 foo1]"(
anatofuz
parents:
diff changeset
97 // CHECK: {{.*}} = alloca
anatofuz
parents:
diff changeset
98 // CHECK: {{.*}} = alloca
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
99 // CHECK: %[[D:.*]] = alloca ptr
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
100 // CHECK: %[[TEMP:.*]] = alloca ptr
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
101 // CHECK: %[[V4:.*]] = load ptr, ptr %[[D]]
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
102 // CHECK: store ptr %[[V4]], ptr %[[TEMP]]
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
103 // CHECK: call void @objc_msgSend(ptr noundef %{{.*}}, ptr noundef %{{.*}}, ptr noundef %[[TEMP]])
150
anatofuz
parents:
diff changeset
104
anatofuz
parents:
diff changeset
105 @interface P0<ObjectType> : NSObject
anatofuz
parents:
diff changeset
106 - (void)m0:(ObjectType *)first;
anatofuz
parents:
diff changeset
107 @end
anatofuz
parents:
diff changeset
108
anatofuz
parents:
diff changeset
109 @interface C0 : NSObject
anatofuz
parents:
diff changeset
110 -(void)foo1;
anatofuz
parents:
diff changeset
111 @end
anatofuz
parents:
diff changeset
112
anatofuz
parents:
diff changeset
113 @implementation C0 {
anatofuz
parents:
diff changeset
114 P0<NSString *> *x;
anatofuz
parents:
diff changeset
115 }
anatofuz
parents:
diff changeset
116
anatofuz
parents:
diff changeset
117 -(void)foo1 {
anatofuz
parents:
diff changeset
118 NSString *d;
anatofuz
parents:
diff changeset
119 [x m0:&d];
anatofuz
parents:
diff changeset
120 }
anatofuz
parents:
diff changeset
121 @end