blob: 2c10fbcb97531634445681c516f83bba53aa04ab [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
90 // CHECK: @_ZN11rdar9357400L2ggE = internal constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00"
91 const char gg[] = @encode(vector4f);
92}
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
100 // CHECK: @_ZN11rdar9624314L2ggE = internal constant [6 x i8] c"{S=i}\00"
101 const char gg[] = @encode(S);
102
103 struct S2 { unsigned : 0; int x; unsigned : 0; };
104 // CHECK: @_ZN11rdar9624314L2g2E = internal constant [11 x i8] c"{S2=b0ib0}\00"
105 const char g2[] = @encode(S2);
106}
107
Argyrios Kyrtzidis26361972011-05-17 00:46:38 +0000108struct Base1 {
109 char x;
110};
111
112struct DBase : public Base1 {
113 double x;
114 virtual ~DBase();
115};
116
117struct Sub_with_virt : virtual DBase {
118 long x;
119};
120
121struct Sub2 : public Sub_with_virt, public Base1, virtual DBase {
122 float x;
123};
124
125// CHECK: @_ZL2g1 = internal constant [10 x i8] c"{Base1=c}\00"
126const char g1[] = @encode(Base1);
127
128// CHECK: @_ZL2g2 = internal constant [14 x i8] c"{DBase=^^?cd}\00"
129const char g2[] = @encode(DBase);
130
131// CHECK: @_ZL2g3 = internal constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00"
132const char g3[] = @encode(Sub_with_virt);
133
134// CHECK: @_ZL2g4 = internal constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00"
135const char g4[] = @encode(Sub2);
136
137// http://llvm.org/PR9927
138class allocator {
139};
140class basic_string {
141struct _Alloc_hider : allocator {
142char* _M_p;
143};
144_Alloc_hider _M_dataplus;
145};
146
147// CHECK: @_ZL2g5 = internal constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00"
148const char g5[] = @encode(basic_string);