blob: e0171efbed8a206461b56148ba7754050de035a1 [file] [log] [blame]
Fariborz Jahanian6fb94392010-05-07 00:28:49 +00001// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2
3// CHECK: v17@0:8{vector<float, float, float>=}16
4// CHECK: {vector<float, float, float>=}
John McCall532ec7b2010-05-17 23:56:34 +00005// CHECK: v24@0:816
Fariborz Jahanian6fb94392010-05-07 00:28:49 +00006
7template <typename T1, typename T2, typename T3> struct vector {
Douglas Gregor68dd3ee2010-05-20 02:24:22 +00008 vector();
9 vector(T1,T2,T3);
Fariborz Jahanian6fb94392010-05-07 00:28:49 +000010};
11
12typedef vector< float, float, float > vector3f;
13
14@interface SceneNode
15{
16 vector3f position;
17}
18
19@property (assign, nonatomic) vector3f position;
20
21@end
22
23@interface MyOpenGLView
24{
25@public
26 vector3f position;
27}
28@property vector3f position;
29@end
30
31@implementation MyOpenGLView
32
33@synthesize position;
34
35-(void)awakeFromNib {
36 SceneNode *sn;
37 vector3f VF3(1.0, 1.0, 1.0);
38 [sn setPosition:VF3];
39}
40@end
John McCall532ec7b2010-05-17 23:56:34 +000041
42
43class Int3 { int x, y, z; };
44
45// Enforce @encoding for member pointers.
46@interface MemPtr {}
47- (void) foo: (int (Int3::*)) member;
48@end
49@implementation MemPtr
50- (void) foo: (int (Int3::*)) member {
51}
52@end
Fariborz Jahaniane6012c72010-10-07 21:25:25 +000053
54// rdar: // 8519948
55typedef float HGVec4f __attribute__ ((vector_size(16)));
56
57@interface RedBalloonHGXFormWrapper {
58 HGVec4f m_Transform[4];
59}
60@end
61
62@implementation RedBalloonHGXFormWrapper
63@end
64
Argyrios Kyrtzidis26361972011-05-17 00:46:38 +000065// rdar://9357400
66namespace rdar9357400 {
67 template<int Dim1 = -1, int Dim2 = -1> struct fixed {
68 template<int D> struct rebind { typedef fixed<D> other; };
69 };
70
71 template<typename Element, int Size>
72 class fixed_1D
73 {
74 public:
75 typedef Element value_type;
76 typedef value_type array_impl[Size];
77 protected:
78 array_impl m_data;
79 };
80
81 template<typename Element, typename Alloc>
82 class vector;
83
84 template<typename Element, int Size>
85 class vector< Element, fixed<Size> >
86 : public fixed_1D<Element,Size> { };
87
88 typedef vector< float, fixed<4> > vector4f;
89
Richard Smith8ae4ec22012-08-07 04:16:51 +000090 // CHECK: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00"
91 extern const char gg[] = @encode(vector4f);
Argyrios Kyrtzidis26361972011-05-17 00:46:38 +000092}
93
Argyrios Kyrtzidis829f2002011-06-17 23:19:38 +000094// rdar://9624314
95namespace rdar9624314 {
96 struct B2 { int x; };
97 struct B3 {};
98 struct S : B2, B3 {};
99
Richard Smith8ae4ec22012-08-07 04:16:51 +0000100 // CHECK: @_ZN11rdar96243142ggE = constant [6 x i8] c"{S=i}\00"
101 extern const char gg[] = @encode(S);
Argyrios Kyrtzidis829f2002011-06-17 23:19:38 +0000102
103 struct S2 { unsigned : 0; int x; unsigned : 0; };
Richard Smith8ae4ec22012-08-07 04:16:51 +0000104 // CHECK: @_ZN11rdar96243142g2E = constant [11 x i8] c"{S2=b0ib0}\00"
105 extern const char g2[] = @encode(S2);
Argyrios Kyrtzidis829f2002011-06-17 23:19:38 +0000106}
107
Argyrios Kyrtzidiscb8061e2011-08-22 16:03:14 +0000108namespace test {
109 class Foo {
110 public:
111 virtual void f() {};
112 };
113
114 class Bar {
115 public:
116 virtual void g() {};
117 };
118
119 class Zoo : virtual public Foo, virtual public Bar {
120 public:
121 int x;
122 int y;
123 };
124
Richard Smith8ae4ec22012-08-07 04:16:51 +0000125 // CHECK: @_ZN4test3ecdE = constant [15 x i8] c"{Zoo=^^?ii^^?}\00"
126 extern const char ecd[] = @encode(Zoo);
Argyrios Kyrtzidiscb8061e2011-08-22 16:03:14 +0000127}
128
Argyrios Kyrtzidis26361972011-05-17 00:46:38 +0000129struct Base1 {
130 char x;
131};
132
133struct DBase : public Base1 {
134 double x;
135 virtual ~DBase();
136};
137
138struct Sub_with_virt : virtual DBase {
139 long x;
140};
141
142struct Sub2 : public Sub_with_virt, public Base1, virtual DBase {
143 float x;
144};
145
Richard Smith8ae4ec22012-08-07 04:16:51 +0000146// CHECK: @g1 = constant [10 x i8] c"{Base1=c}\00"
147extern const char g1[] = @encode(Base1);
Argyrios Kyrtzidis26361972011-05-17 00:46:38 +0000148
Richard Smith8ae4ec22012-08-07 04:16:51 +0000149// CHECK: @g2 = constant [14 x i8] c"{DBase=^^?cd}\00"
150extern const char g2[] = @encode(DBase);
Argyrios Kyrtzidis26361972011-05-17 00:46:38 +0000151
Richard Smith8ae4ec22012-08-07 04:16:51 +0000152// CHECK: @g3 = constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00"
153extern const char g3[] = @encode(Sub_with_virt);
Argyrios Kyrtzidis26361972011-05-17 00:46:38 +0000154
Richard Smith8ae4ec22012-08-07 04:16:51 +0000155// CHECK: @g4 = constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00"
156extern const char g4[] = @encode(Sub2);
Argyrios Kyrtzidis26361972011-05-17 00:46:38 +0000157
158// http://llvm.org/PR9927
159class allocator {
160};
161class basic_string {
162struct _Alloc_hider : allocator {
163char* _M_p;
164};
165_Alloc_hider _M_dataplus;
166};
167
Richard Smith8ae4ec22012-08-07 04:16:51 +0000168// CHECK: @g5 = constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00"
169extern const char g5[] = @encode(basic_string);
Argyrios Kyrtzidis19aa8602011-09-26 18:14:24 +0000170
171
172// PR10990
173class CefBase {
174 virtual ~CefBase() {}
175};
176class CefBrowser : public virtual CefBase {};
177class CefBrowserImpl : public CefBrowser {};
Richard Smith8ae4ec22012-08-07 04:16:51 +0000178// CHECK: @g6 = constant [21 x i8] c"{CefBrowserImpl=^^?}\00"
179extern const char g6[] = @encode(CefBrowserImpl);
Argyrios Kyrtzidis19aa8602011-09-26 18:14:24 +0000180
181// PR10990_2
182class CefBase2 {
183 virtual ~CefBase2() {}
184 int i;
185};
186class CefBrowser2 : public virtual CefBase2 {};
187class CefBrowserImpl2 : public CefBrowser2 {};
Richard Smith8ae4ec22012-08-07 04:16:51 +0000188// CHECK: @g7 = constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00"
189extern const char g7[] = @encode(CefBrowserImpl2);
Douglas Gregor58db7a52012-04-27 22:30:01 +0000190
191// <rdar://problem/11324167>
192struct Empty {};
193
194struct X : Empty {
195 int array[10];
196};
197
198struct Y : Empty {
199 X vec;
200};
201
Richard Smith8ae4ec22012-08-07 04:16:51 +0000202// CHECK: @g8 = constant [14 x i8] c"{Y={X=[10i]}}\00"
203extern const char g8[] = @encode(Y);
Eli Friedmanb4c0ad42013-06-17 23:57:41 +0000204
205
206class dynamic_class {
207public:
208 virtual ~dynamic_class();
209};
210@interface has_dynamic_class_ivar
211@end
212@implementation has_dynamic_class_ivar {
213 dynamic_class dynamic_class_ivar;
214}
215@end
Stephen Hines651f13c2014-04-23 16:59:28 -0700216// CHECK: private global [41 x i8] c"{dynamic_class=\22_vptr$dynamic_class\22^^?}\00"
Eli Friedman1a973442013-09-18 01:59:16 +0000217
218namespace PR17142 {
219 struct A { virtual ~A(); };
220 struct B : virtual A { int y; };
221 struct C { virtual ~C(); int z; };
222 struct D : C, B { int a; };
223 struct E : D {};
224 // CHECK: @_ZN7PR171421xE = constant [14 x i8] c"{E=^^?i^^?ii}\00"
225 extern const char x[] = @encode(E);
226}