Fariborz Jahanian | 6fb9439 | 2010-05-07 00:28:49 +0000 | [diff] [blame] | 1 | // 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 McCall | 532ec7b | 2010-05-17 23:56:34 +0000 | [diff] [blame] | 5 | // CHECK: v24@0:816 |
Fariborz Jahanian | 6fb9439 | 2010-05-07 00:28:49 +0000 | [diff] [blame] | 6 | |
| 7 | template <typename T1, typename T2, typename T3> struct vector { |
Douglas Gregor | 68dd3ee | 2010-05-20 02:24:22 +0000 | [diff] [blame] | 8 | vector(); |
| 9 | vector(T1,T2,T3); |
Fariborz Jahanian | 6fb9439 | 2010-05-07 00:28:49 +0000 | [diff] [blame] | 10 | }; |
| 11 | |
| 12 | typedef 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 McCall | 532ec7b | 2010-05-17 23:56:34 +0000 | [diff] [blame] | 41 | |
| 42 | |
| 43 | class 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 Jahanian | e6012c7 | 2010-10-07 21:25:25 +0000 | [diff] [blame] | 53 | |
| 54 | // rdar: // 8519948 |
| 55 | typedef 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 Kyrtzidis | 2636197 | 2011-05-17 00:46:38 +0000 | [diff] [blame] | 65 | // rdar://9357400 |
| 66 | namespace 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 Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 90 | // CHECK: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00" |
| 91 | extern const char gg[] = @encode(vector4f); |
Argyrios Kyrtzidis | 2636197 | 2011-05-17 00:46:38 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Argyrios Kyrtzidis | 829f200 | 2011-06-17 23:19:38 +0000 | [diff] [blame] | 94 | // rdar://9624314 |
| 95 | namespace rdar9624314 { |
| 96 | struct B2 { int x; }; |
| 97 | struct B3 {}; |
| 98 | struct S : B2, B3 {}; |
| 99 | |
Richard Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 100 | // CHECK: @_ZN11rdar96243142ggE = constant [6 x i8] c"{S=i}\00" |
| 101 | extern const char gg[] = @encode(S); |
Argyrios Kyrtzidis | 829f200 | 2011-06-17 23:19:38 +0000 | [diff] [blame] | 102 | |
| 103 | struct S2 { unsigned : 0; int x; unsigned : 0; }; |
Richard Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 104 | // CHECK: @_ZN11rdar96243142g2E = constant [11 x i8] c"{S2=b0ib0}\00" |
| 105 | extern const char g2[] = @encode(S2); |
Argyrios Kyrtzidis | 829f200 | 2011-06-17 23:19:38 +0000 | [diff] [blame] | 106 | } |
| 107 | |
Argyrios Kyrtzidis | cb8061e | 2011-08-22 16:03:14 +0000 | [diff] [blame] | 108 | namespace 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 Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 125 | // CHECK: @_ZN4test3ecdE = constant [15 x i8] c"{Zoo=^^?ii^^?}\00" |
| 126 | extern const char ecd[] = @encode(Zoo); |
Argyrios Kyrtzidis | cb8061e | 2011-08-22 16:03:14 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Argyrios Kyrtzidis | 2636197 | 2011-05-17 00:46:38 +0000 | [diff] [blame] | 129 | struct Base1 { |
| 130 | char x; |
| 131 | }; |
| 132 | |
| 133 | struct DBase : public Base1 { |
| 134 | double x; |
| 135 | virtual ~DBase(); |
| 136 | }; |
| 137 | |
| 138 | struct Sub_with_virt : virtual DBase { |
| 139 | long x; |
| 140 | }; |
| 141 | |
| 142 | struct Sub2 : public Sub_with_virt, public Base1, virtual DBase { |
| 143 | float x; |
| 144 | }; |
| 145 | |
Richard Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 146 | // CHECK: @g1 = constant [10 x i8] c"{Base1=c}\00" |
| 147 | extern const char g1[] = @encode(Base1); |
Argyrios Kyrtzidis | 2636197 | 2011-05-17 00:46:38 +0000 | [diff] [blame] | 148 | |
Richard Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 149 | // CHECK: @g2 = constant [14 x i8] c"{DBase=^^?cd}\00" |
| 150 | extern const char g2[] = @encode(DBase); |
Argyrios Kyrtzidis | 2636197 | 2011-05-17 00:46:38 +0000 | [diff] [blame] | 151 | |
Richard Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 152 | // CHECK: @g3 = constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00" |
| 153 | extern const char g3[] = @encode(Sub_with_virt); |
Argyrios Kyrtzidis | 2636197 | 2011-05-17 00:46:38 +0000 | [diff] [blame] | 154 | |
Richard Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 155 | // CHECK: @g4 = constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00" |
| 156 | extern const char g4[] = @encode(Sub2); |
Argyrios Kyrtzidis | 2636197 | 2011-05-17 00:46:38 +0000 | [diff] [blame] | 157 | |
| 158 | // http://llvm.org/PR9927 |
| 159 | class allocator { |
| 160 | }; |
| 161 | class basic_string { |
| 162 | struct _Alloc_hider : allocator { |
| 163 | char* _M_p; |
| 164 | }; |
| 165 | _Alloc_hider _M_dataplus; |
| 166 | }; |
| 167 | |
Richard Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 168 | // CHECK: @g5 = constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00" |
| 169 | extern const char g5[] = @encode(basic_string); |
Argyrios Kyrtzidis | 19aa860 | 2011-09-26 18:14:24 +0000 | [diff] [blame] | 170 | |
| 171 | |
| 172 | // PR10990 |
| 173 | class CefBase { |
| 174 | virtual ~CefBase() {} |
| 175 | }; |
| 176 | class CefBrowser : public virtual CefBase {}; |
| 177 | class CefBrowserImpl : public CefBrowser {}; |
Richard Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 178 | // CHECK: @g6 = constant [21 x i8] c"{CefBrowserImpl=^^?}\00" |
| 179 | extern const char g6[] = @encode(CefBrowserImpl); |
Argyrios Kyrtzidis | 19aa860 | 2011-09-26 18:14:24 +0000 | [diff] [blame] | 180 | |
| 181 | // PR10990_2 |
| 182 | class CefBase2 { |
| 183 | virtual ~CefBase2() {} |
| 184 | int i; |
| 185 | }; |
| 186 | class CefBrowser2 : public virtual CefBase2 {}; |
| 187 | class CefBrowserImpl2 : public CefBrowser2 {}; |
Richard Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 188 | // CHECK: @g7 = constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00" |
| 189 | extern const char g7[] = @encode(CefBrowserImpl2); |
Douglas Gregor | 58db7a5 | 2012-04-27 22:30:01 +0000 | [diff] [blame] | 190 | |
| 191 | // <rdar://problem/11324167> |
| 192 | struct Empty {}; |
| 193 | |
| 194 | struct X : Empty { |
| 195 | int array[10]; |
| 196 | }; |
| 197 | |
| 198 | struct Y : Empty { |
| 199 | X vec; |
| 200 | }; |
| 201 | |
Richard Smith | 8ae4ec2 | 2012-08-07 04:16:51 +0000 | [diff] [blame] | 202 | // CHECK: @g8 = constant [14 x i8] c"{Y={X=[10i]}}\00" |
| 203 | extern const char g8[] = @encode(Y); |
Eli Friedman | b4c0ad4 | 2013-06-17 23:57:41 +0000 | [diff] [blame] | 204 | |
| 205 | |
| 206 | class dynamic_class { |
| 207 | public: |
| 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 |
| 216 | // CHECK: internal global [41 x i8] c"{dynamic_class=\22_vptr$dynamic_class\22^^?}\00" |