• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX98 %s
2// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX20 %s
3
4// CHECK: v17@0:8{vector<float, float, float>=}16
5// CHECK: {vector<float, float, float>=}
6// CHECK: v24@0:816
7
8template <typename T1, typename T2, typename T3> struct vector {
9  vector();
10  vector(T1,T2,T3);
11};
12
13typedef vector< float, float, float > vector3f;
14
15@interface SceneNode
16{
17 vector3f position;
18}
19
20@property (assign, nonatomic) vector3f position;
21
22@end
23
24@interface MyOpenGLView
25{
26@public
27  vector3f position;
28}
29@property vector3f position;
30@end
31
32@implementation MyOpenGLView
33
34@synthesize position;
35
36-(void)awakeFromNib {
37 SceneNode *sn;
38 vector3f VF3(1.0, 1.0, 1.0);
39 [sn setPosition:VF3];
40}
41@end
42
43
44class Int3 { int x, y, z; };
45
46// Enforce @encoding for member pointers.
47@interface MemPtr {}
48- (void) foo: (int (Int3::*)) member;
49@end
50@implementation MemPtr
51- (void) foo: (int (Int3::*)) member {
52}
53@end
54
55// rdar: // 8519948
56typedef float HGVec4f __attribute__ ((vector_size(16)));
57
58@interface RedBalloonHGXFormWrapper {
59  HGVec4f m_Transform[4];
60}
61@end
62
63@implementation RedBalloonHGXFormWrapper
64@end
65
66// rdar://9357400
67namespace rdar9357400 {
68  template<int Dim1 = -1, int Dim2 = -1> struct fixed {
69      template<int D> struct rebind { typedef fixed<D> other; };
70  };
71
72  template<typename Element, int Size>
73  class fixed_1D
74  {
75  public:
76      typedef Element value_type;
77      typedef value_type array_impl[Size];
78    protected:
79      array_impl                  m_data;
80  };
81
82  template<typename Element, typename Alloc>
83  class vector;
84
85  template<typename Element, int Size>
86  class vector< Element, fixed<Size> >
87  : public fixed_1D<Element,Size> { };
88
89  typedef vector< float,  fixed<4> > vector4f;
90
91  // FIXME: This difference is due to D76801. It was probably an unintentional change. Maybe we want to undo it?
92  // CHECKCXX98: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00"
93  // CHECKCXX20: @_ZN11rdar93574002ggE = constant [48 x i8] c"{vector<float, rdar9357400::fixed<4, -1>>=[4f]}\00"
94  extern const char gg[] = @encode(vector4f);
95}
96
97// rdar://9624314
98namespace rdar9624314 {
99  struct B2 { int x; };
100  struct B3 {};
101  struct S : B2, B3 {};
102
103  // CHECK: @_ZN11rdar96243142ggE = constant [6 x i8] c"{S=i}\00"
104  extern const char gg[] = @encode(S);
105
106  struct S2 { unsigned : 0; int x; unsigned : 0; };
107  // CHECK: @_ZN11rdar96243142g2E = constant [11 x i8] c"{S2=b0ib0}\00"
108  extern const char g2[] = @encode(S2);
109}
110
111namespace test {
112  class Foo {
113  public:
114   virtual void f() {};
115  };
116
117  class Bar {
118  public:
119   virtual void g() {};
120  };
121
122  class Zoo : virtual public Foo, virtual public Bar {
123  public:
124   int x;
125   int y;
126  };
127
128  // CHECK: @_ZN4test3ecdE = constant [15 x i8] c"{Zoo=^^?ii^^?}\00"
129  extern const char ecd[] = @encode(Zoo);
130}
131
132struct Base1 {
133  char x;
134};
135
136struct DBase : public Base1 {
137  double x;
138  virtual ~DBase();
139};
140
141struct Sub_with_virt : virtual DBase {
142  long x;
143};
144
145struct Sub2 : public Sub_with_virt, public Base1, virtual DBase {
146  float x;
147};
148
149// CHECK: @g1 = constant [10 x i8] c"{Base1=c}\00"
150extern const char g1[] = @encode(Base1);
151
152// CHECK: @g2 = constant [14 x i8] c"{DBase=^^?cd}\00"
153extern const char g2[] = @encode(DBase);
154
155// CHECK: @g3 = constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00"
156extern const char g3[] = @encode(Sub_with_virt);
157
158// CHECK: @g4 = constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00"
159extern const char g4[] = @encode(Sub2);
160
161// http://llvm.org/PR9927
162class allocator {
163};
164class basic_string     {
165struct _Alloc_hider : allocator       {
166char* _M_p;
167};
168_Alloc_hider _M_dataplus;
169};
170
171// CHECK: @g5 = constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00"
172extern const char g5[] = @encode(basic_string);
173
174
175// PR10990
176struct CefBase {
177  virtual ~CefBase() {}
178};
179struct CefBrowser : public virtual CefBase {};
180struct CefBrowserImpl : public CefBrowser {};
181// CHECK: @g6 = constant [21 x i8] c"{CefBrowserImpl=^^?}\00"
182extern const char g6[] = @encode(CefBrowserImpl);
183
184// PR10990_2
185struct CefBase2 {
186  virtual ~CefBase2() {}
187  int i;
188};
189struct CefBrowser2 : public virtual CefBase2 {};
190struct CefBrowserImpl2 : public CefBrowser2 {};
191// CHECK: @g7 = constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00"
192extern const char g7[] = @encode(CefBrowserImpl2);
193
194// <rdar://problem/11324167>
195struct Empty {};
196
197struct X : Empty {
198  int array[10];
199};
200
201struct Y : Empty {
202  X vec;
203};
204
205// CHECK: @g8 = constant [14 x i8] c"{Y={X=[10i]}}\00"
206extern const char g8[] = @encode(Y);
207
208
209class dynamic_class {
210public:
211  virtual ~dynamic_class();
212};
213@interface has_dynamic_class_ivar
214@end
215@implementation has_dynamic_class_ivar {
216  dynamic_class dynamic_class_ivar;
217}
218@end
219// CHECK: private unnamed_addr constant [41 x i8] c"{dynamic_class=\22_vptr$dynamic_class\22^^?}\00"
220
221namespace PR17142 {
222  struct A { virtual ~A(); };
223  struct B : virtual A { int y; };
224  struct C { virtual ~C(); int z; };
225  struct D : C, B { int a; };
226  struct E : D {};
227  // CHECK: @_ZN7PR171421xE = constant [14 x i8] c"{E=^^?i^^?ii}\00"
228  extern const char x[] = @encode(E);
229}
230
231// This test used to cause infinite recursion.
232template<typename T>
233struct S {
234  typedef T Ty;
235  Ty *t;
236};
237
238@interface N
239{
240  S<N> a;
241}
242@end
243
244@implementation N
245@end
246
247const char *expand_struct() {
248  // CHECK: @{{.*}} = private unnamed_addr constant [13 x i8] c"{N={S<N>=@}}\00"
249  return @encode(N);
250}
251
252#if __cplusplus >= 202002L
253namespace PR48048 {
254  struct F {};
255  struct I {
256    int m;
257    [[no_unique_address]] F n;
258  };
259  // CHECKCXX20: @_ZN7PR480481xE = constant [6 x i8] c"{I=i}\00"
260  extern const char x[] = @encode(I);
261}
262#endif
263