blob: bfc4ae9e754685bdc4e772440e4e9ab1d0c268a2 [file] [log] [blame]
Daniel Dunbar0bf21992009-04-15 02:56:18 +00001// RUN: clang-cc -triple x86_64-apple-darwin9 -emit-llvm -o %t %s &&
2// RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s &&
3
4// RUN: grep '@"OBJC_CLASS_$_A" = global' %t &&
5// RUN: grep '@"OBJC_CLASS_$_B" = external global' %t &&
Daniel Dunbar7595fb12009-04-15 19:52:32 +00006// RUN: grep '@"OBJC_IVAR_$_A._ivar" = global .* section "__DATA, __objc_const", align 8' %t &&
Daniel Dunbar0bf21992009-04-15 02:56:18 +00007// RUN: grep '@"OBJC_METACLASS_$_A" = global .* section "__DATA, __objc_data", align 8' %t &&
8// RUN: grep '@"\\01L_OBJC_CLASSLIST_REFERENCES_$_[0-9]*" = internal global .* section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8' %t &&
Daniel Dunbar33af70f2009-04-15 19:03:14 +00009// RUN: grep '@"\\01L_OBJC_CLASSLIST_SUP_REFS_$_[0-9]*" = internal global .* section "__DATA, __objc_superrefs, regular, no_dead_strip", align 8' %t | count 2 &&
Daniel Dunbar0bf21992009-04-15 02:56:18 +000010// RUN: grep '@"\\01L_OBJC_CLASS_NAME_[0-9]*" = internal global .* section "__TEXT,__cstring,cstring_literals", align 1' %t &&
11// RUN: grep '@"\\01L_OBJC_LABEL_CATEGORY_$" = internal global .* section "__DATA, __objc_catlist, regular, no_dead_strip", align 8' %t &&
12// RUN: grep '@"\\01L_OBJC_LABEL_CLASS_$" = internal global .* section "__DATA, __objc_classlist, regular, no_dead_strip", align 8' %t &&
13// RUN: grep '@"\\01L_OBJC_METH_VAR_NAME_[0-9]*" = internal global .* section "__TEXT,__cstring,cstring_literals", align 1' %t &&
14// RUN: grep '@"\\01L_OBJC_METH_VAR_TYPE_[0-9]*" = internal global .* section "__TEXT,__cstring,cstring_literals", align 1' %t &&
15// RUN: grep '@"\\01L_OBJC_PROP_NAME_ATTR_[0-9]*" = internal global .* section "__TEXT,__cstring,cstring_literals", align 1' %t &&
Fariborz Jahaniand0f8a8d2009-05-11 19:25:47 +000016// RUN: grep '@"\\01L_OBJC_SELECTOR_REFERENCES_*" = internal global .* section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"' %t &&
Daniel Dunbar0bf21992009-04-15 02:56:18 +000017// RUN: grep '@"\\01l_OBJC_$_CATEGORY_A_$_Cat" = internal global .* section "__DATA, __objc_const", align 8' %t &&
18// RUN: grep '@"\\01l_OBJC_$_CATEGORY_CLASS_METHODS_A_$_Cat" = internal global .* section "__DATA, __objc_const", align 8' %t &&
19// RUN: grep '@"\\01l_OBJC_$_CATEGORY_INSTANCE_METHODS_A_$_Cat" = internal global .* section "__DATA, __objc_const", align 8' %t &&
20// RUN: grep '@"\\01l_OBJC_$_CLASS_METHODS_A" = internal global .* section "__DATA, __objc_const", align 8' %t &&
21// RUN: grep '@"\\01l_OBJC_$_INSTANCE_METHODS_A" = internal global .* section "__DATA, __objc_const", align 8' %t &&
22// RUN: grep '@"\\01l_OBJC_$_INSTANCE_VARIABLES_A" = internal global .* section "__DATA, __objc_const", align 8' %t &&
23// RUN: grep '@"\\01l_OBJC_$_PROP_LIST_A" = internal global .* section "__DATA, __objc_const", align 8' %t &&
24// RUN: grep '@"\\01l_OBJC_$_PROTOCOL_CLASS_METHODS_P" = internal global .* section "__DATA, __objc_const", align 8' %t &&
25// RUN: grep '@"\\01l_OBJC_$_PROTOCOL_INSTANCE_METHODS_P" = internal global .* section "__DATA, __objc_const", align 8' %t &&
26// RUN: grep '@"\\01l_OBJC_CLASS_PROTOCOLS_$_A" = internal global .* section "__DATA, __objc_const", align 8' %t &&
27// RUN: grep '@"\\01l_OBJC_CLASS_RO_$_A" = internal global .* section "__DATA, __objc_const", align 8' %t &&
28// RUN: grep '@"\\01l_OBJC_LABEL_PROTOCOL_$_P" = weak hidden global .* section "__DATA, __objc_protolist, coalesced, no_dead_strip", align 8' %t &&
29// RUN: grep '@"\\01l_OBJC_METACLASS_RO_$_A" = internal global .* section "__DATA, __objc_const", align 8' %t &&
30// RUN: grep '@"\\01l_OBJC_PROTOCOL_$_P" = weak hidden global .* section "__DATA,__datacoal_nt,coalesced", align 8' %t &&
Daniel Dunbarf59c1a62009-04-15 19:04:46 +000031// RUN: grep '@"\\01l_objc_msgSend_fixup_alloc" = weak hidden global .* section "__DATA, __objc_msgrefs, coalesced", align 16' %t &&
Daniel Dunbar0bf21992009-04-15 02:56:18 +000032// RUN: grep '@_objc_empty_cache = external global' %t &&
33// RUN: grep '@_objc_empty_vtable = external global' %t &&
Fariborz Jahanian5b2bad02009-04-30 16:31:11 +000034// RUN: grep '@objc_msgSend_fixup(' %t &&
Fariborz Jahaniand0f8a8d2009-05-11 19:25:47 +000035// RUN: grep '@objc_msgSend_fpret(' %t &&
Daniel Dunbar0bf21992009-04-15 02:56:18 +000036
37// RUN: true
38
39/*
40
41Here is a handy command for looking at llvm-gcc's output:
42llvm-gcc -m64 -emit-llvm -S -o - metadata-symbols-64.m | \
43 grep '=.*global' | \
44 sed -e 's#global.*, section#global ... section#' | \
45 sort
46
47*/
48
49@interface B
50@end
51@interface C
52@end
53
54@protocol P
55+(void) fm0;
56-(void) im0;
57@end
58
59@interface A<P> {
60 int _ivar;
61}
62
63@property (assign) int ivar;
64
65+(void) fm0;
66-(void) im0;
67@end
68
69@implementation A
70@synthesize ivar = _ivar;
71+(void) fm0 {
72}
73-(void) im0 {
74}
75@end
76
77@implementation A (Cat)
78+(void) fm1 {
79}
80-(void) im1 {
81}
82@end
83
Daniel Dunbar33af70f2009-04-15 19:03:14 +000084@interface D : A
85@end
86
87@implementation D
88+(void) fm2 {
89 [super fm1];
90}
91-(void) im2 {
92 [super im1];
93}
94@end
95
Fariborz Jahanian5b2bad02009-04-30 16:31:11 +000096// Test for FP dispatch method APIs
97@interface Example
98@end
99
100float FLOAT;
101double DOUBLE;
102long double LONGDOUBLE;
103id ID;
104
105@implementation Example
106 - (double) RET_DOUBLE
107 {
108 return DOUBLE;
109 }
110 - (float) RET_FLOAT
111 {
112 return FLOAT;
113 }
114 - (long double) RET_LONGDOUBLE
115 {
116 return LONGDOUBLE;
117 }
118@end
119
Daniel Dunbar33af70f2009-04-15 19:03:14 +0000120void *f0(id x) {
Fariborz Jahanian5b2bad02009-04-30 16:31:11 +0000121 Example* pe;
122 double dd = [pe RET_DOUBLE];
123 dd = [pe RET_FLOAT];
124 dd = [pe RET_LONGDOUBLE];
125
Daniel Dunbar0bf21992009-04-15 02:56:18 +0000126 [B im0];
127 [C im1];
Daniel Dunbar33af70f2009-04-15 19:03:14 +0000128 [D alloc];
Daniel Dunbar0bf21992009-04-15 02:56:18 +0000129}
130