1f4a2713aSLionel Sambuc// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuc// CHECK: v17@0:8{vector<float, float, float>=}16 4f4a2713aSLionel Sambuc// CHECK: {vector<float, float, float>=} 5f4a2713aSLionel Sambuc// CHECK: v24@0:816 6f4a2713aSLionel Sambuc 7f4a2713aSLionel Sambuctemplate <typename T1, typename T2, typename T3> struct vector { 8f4a2713aSLionel Sambuc vector(); 9f4a2713aSLionel Sambuc vector(T1,T2,T3); 10f4a2713aSLionel Sambuc}; 11f4a2713aSLionel Sambuc 12f4a2713aSLionel Sambuctypedef vector< float, float, float > vector3f; 13f4a2713aSLionel Sambuc 14f4a2713aSLionel Sambuc@interface SceneNode 15f4a2713aSLionel Sambuc{ 16f4a2713aSLionel Sambuc vector3f position; 17f4a2713aSLionel Sambuc} 18f4a2713aSLionel Sambuc 19f4a2713aSLionel Sambuc@property (assign, nonatomic) vector3f position; 20f4a2713aSLionel Sambuc 21f4a2713aSLionel Sambuc@end 22f4a2713aSLionel Sambuc 23f4a2713aSLionel Sambuc@interface MyOpenGLView 24f4a2713aSLionel Sambuc{ 25f4a2713aSLionel Sambuc@public 26f4a2713aSLionel Sambuc vector3f position; 27f4a2713aSLionel Sambuc} 28f4a2713aSLionel Sambuc@property vector3f position; 29f4a2713aSLionel Sambuc@end 30f4a2713aSLionel Sambuc 31f4a2713aSLionel Sambuc@implementation MyOpenGLView 32f4a2713aSLionel Sambuc 33f4a2713aSLionel Sambuc@synthesize position; 34f4a2713aSLionel Sambuc 35f4a2713aSLionel Sambuc-(void)awakeFromNib { 36f4a2713aSLionel Sambuc SceneNode *sn; 37f4a2713aSLionel Sambuc vector3f VF3(1.0, 1.0, 1.0); 38f4a2713aSLionel Sambuc [sn setPosition:VF3]; 39f4a2713aSLionel Sambuc} 40f4a2713aSLionel Sambuc@end 41f4a2713aSLionel Sambuc 42f4a2713aSLionel Sambuc 43f4a2713aSLionel Sambucclass Int3 { int x, y, z; }; 44f4a2713aSLionel Sambuc 45f4a2713aSLionel Sambuc// Enforce @encoding for member pointers. 46f4a2713aSLionel Sambuc@interface MemPtr {} 47f4a2713aSLionel Sambuc- (void) foo: (int (Int3::*)) member; 48f4a2713aSLionel Sambuc@end 49f4a2713aSLionel Sambuc@implementation MemPtr 50f4a2713aSLionel Sambuc- (void) foo: (int (Int3::*)) member { 51f4a2713aSLionel Sambuc} 52f4a2713aSLionel Sambuc@end 53f4a2713aSLionel Sambuc 54f4a2713aSLionel Sambuc// rdar: // 8519948 55f4a2713aSLionel Sambuctypedef float HGVec4f __attribute__ ((vector_size(16))); 56f4a2713aSLionel Sambuc 57f4a2713aSLionel Sambuc@interface RedBalloonHGXFormWrapper { 58f4a2713aSLionel Sambuc HGVec4f m_Transform[4]; 59f4a2713aSLionel Sambuc} 60f4a2713aSLionel Sambuc@end 61f4a2713aSLionel Sambuc 62f4a2713aSLionel Sambuc@implementation RedBalloonHGXFormWrapper 63f4a2713aSLionel Sambuc@end 64f4a2713aSLionel Sambuc 65f4a2713aSLionel Sambuc// rdar://9357400 66f4a2713aSLionel Sambucnamespace rdar9357400 { 67f4a2713aSLionel Sambuc template<int Dim1 = -1, int Dim2 = -1> struct fixed { 68f4a2713aSLionel Sambuc template<int D> struct rebind { typedef fixed<D> other; }; 69f4a2713aSLionel Sambuc }; 70f4a2713aSLionel Sambuc 71f4a2713aSLionel Sambuc template<typename Element, int Size> 72f4a2713aSLionel Sambuc class fixed_1D 73f4a2713aSLionel Sambuc { 74f4a2713aSLionel Sambuc public: 75f4a2713aSLionel Sambuc typedef Element value_type; 76f4a2713aSLionel Sambuc typedef value_type array_impl[Size]; 77f4a2713aSLionel Sambuc protected: 78f4a2713aSLionel Sambuc array_impl m_data; 79f4a2713aSLionel Sambuc }; 80f4a2713aSLionel Sambuc 81f4a2713aSLionel Sambuc template<typename Element, typename Alloc> 82f4a2713aSLionel Sambuc class vector; 83f4a2713aSLionel Sambuc 84f4a2713aSLionel Sambuc template<typename Element, int Size> 85f4a2713aSLionel Sambuc class vector< Element, fixed<Size> > 86f4a2713aSLionel Sambuc : public fixed_1D<Element,Size> { }; 87f4a2713aSLionel Sambuc 88f4a2713aSLionel Sambuc typedef vector< float, fixed<4> > vector4f; 89f4a2713aSLionel Sambuc 90f4a2713aSLionel Sambuc // CHECK: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00" 91f4a2713aSLionel Sambuc extern const char gg[] = @encode(vector4f); 92f4a2713aSLionel Sambuc} 93f4a2713aSLionel Sambuc 94f4a2713aSLionel Sambuc// rdar://9624314 95f4a2713aSLionel Sambucnamespace rdar9624314 { 96f4a2713aSLionel Sambuc struct B2 { int x; }; 97f4a2713aSLionel Sambuc struct B3 {}; 98f4a2713aSLionel Sambuc struct S : B2, B3 {}; 99f4a2713aSLionel Sambuc 100f4a2713aSLionel Sambuc // CHECK: @_ZN11rdar96243142ggE = constant [6 x i8] c"{S=i}\00" 101f4a2713aSLionel Sambuc extern const char gg[] = @encode(S); 102f4a2713aSLionel Sambuc 103f4a2713aSLionel Sambuc struct S2 { unsigned : 0; int x; unsigned : 0; }; 104f4a2713aSLionel Sambuc // CHECK: @_ZN11rdar96243142g2E = constant [11 x i8] c"{S2=b0ib0}\00" 105f4a2713aSLionel Sambuc extern const char g2[] = @encode(S2); 106f4a2713aSLionel Sambuc} 107f4a2713aSLionel Sambuc 108f4a2713aSLionel Sambucnamespace test { 109f4a2713aSLionel Sambuc class Foo { 110f4a2713aSLionel Sambuc public: 111f4a2713aSLionel Sambuc virtual void f() {}; 112f4a2713aSLionel Sambuc }; 113f4a2713aSLionel Sambuc 114f4a2713aSLionel Sambuc class Bar { 115f4a2713aSLionel Sambuc public: 116f4a2713aSLionel Sambuc virtual void g() {}; 117f4a2713aSLionel Sambuc }; 118f4a2713aSLionel Sambuc 119f4a2713aSLionel Sambuc class Zoo : virtual public Foo, virtual public Bar { 120f4a2713aSLionel Sambuc public: 121f4a2713aSLionel Sambuc int x; 122f4a2713aSLionel Sambuc int y; 123f4a2713aSLionel Sambuc }; 124f4a2713aSLionel Sambuc 125f4a2713aSLionel Sambuc // CHECK: @_ZN4test3ecdE = constant [15 x i8] c"{Zoo=^^?ii^^?}\00" 126f4a2713aSLionel Sambuc extern const char ecd[] = @encode(Zoo); 127f4a2713aSLionel Sambuc} 128f4a2713aSLionel Sambuc 129f4a2713aSLionel Sambucstruct Base1 { 130f4a2713aSLionel Sambuc char x; 131f4a2713aSLionel Sambuc}; 132f4a2713aSLionel Sambuc 133f4a2713aSLionel Sambucstruct DBase : public Base1 { 134f4a2713aSLionel Sambuc double x; 135f4a2713aSLionel Sambuc virtual ~DBase(); 136f4a2713aSLionel Sambuc}; 137f4a2713aSLionel Sambuc 138f4a2713aSLionel Sambucstruct Sub_with_virt : virtual DBase { 139f4a2713aSLionel Sambuc long x; 140f4a2713aSLionel Sambuc}; 141f4a2713aSLionel Sambuc 142f4a2713aSLionel Sambucstruct Sub2 : public Sub_with_virt, public Base1, virtual DBase { 143f4a2713aSLionel Sambuc float x; 144f4a2713aSLionel Sambuc}; 145f4a2713aSLionel Sambuc 146f4a2713aSLionel Sambuc// CHECK: @g1 = constant [10 x i8] c"{Base1=c}\00" 147f4a2713aSLionel Sambucextern const char g1[] = @encode(Base1); 148f4a2713aSLionel Sambuc 149f4a2713aSLionel Sambuc// CHECK: @g2 = constant [14 x i8] c"{DBase=^^?cd}\00" 150f4a2713aSLionel Sambucextern const char g2[] = @encode(DBase); 151f4a2713aSLionel Sambuc 152f4a2713aSLionel Sambuc// CHECK: @g3 = constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00" 153f4a2713aSLionel Sambucextern const char g3[] = @encode(Sub_with_virt); 154f4a2713aSLionel Sambuc 155f4a2713aSLionel Sambuc// CHECK: @g4 = constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00" 156f4a2713aSLionel Sambucextern const char g4[] = @encode(Sub2); 157f4a2713aSLionel Sambuc 158f4a2713aSLionel Sambuc// http://llvm.org/PR9927 159f4a2713aSLionel Sambucclass allocator { 160f4a2713aSLionel Sambuc}; 161f4a2713aSLionel Sambucclass basic_string { 162f4a2713aSLionel Sambucstruct _Alloc_hider : allocator { 163f4a2713aSLionel Sambucchar* _M_p; 164f4a2713aSLionel Sambuc}; 165f4a2713aSLionel Sambuc_Alloc_hider _M_dataplus; 166f4a2713aSLionel Sambuc}; 167f4a2713aSLionel Sambuc 168f4a2713aSLionel Sambuc// CHECK: @g5 = constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00" 169f4a2713aSLionel Sambucextern const char g5[] = @encode(basic_string); 170f4a2713aSLionel Sambuc 171f4a2713aSLionel Sambuc 172f4a2713aSLionel Sambuc// PR10990 173f4a2713aSLionel Sambucclass CefBase { 174f4a2713aSLionel Sambuc virtual ~CefBase() {} 175f4a2713aSLionel Sambuc}; 176f4a2713aSLionel Sambucclass CefBrowser : public virtual CefBase {}; 177f4a2713aSLionel Sambucclass CefBrowserImpl : public CefBrowser {}; 178f4a2713aSLionel Sambuc// CHECK: @g6 = constant [21 x i8] c"{CefBrowserImpl=^^?}\00" 179f4a2713aSLionel Sambucextern const char g6[] = @encode(CefBrowserImpl); 180f4a2713aSLionel Sambuc 181f4a2713aSLionel Sambuc// PR10990_2 182f4a2713aSLionel Sambucclass CefBase2 { 183f4a2713aSLionel Sambuc virtual ~CefBase2() {} 184f4a2713aSLionel Sambuc int i; 185f4a2713aSLionel Sambuc}; 186f4a2713aSLionel Sambucclass CefBrowser2 : public virtual CefBase2 {}; 187f4a2713aSLionel Sambucclass CefBrowserImpl2 : public CefBrowser2 {}; 188f4a2713aSLionel Sambuc// CHECK: @g7 = constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00" 189f4a2713aSLionel Sambucextern const char g7[] = @encode(CefBrowserImpl2); 190f4a2713aSLionel Sambuc 191f4a2713aSLionel Sambuc// <rdar://problem/11324167> 192f4a2713aSLionel Sambucstruct Empty {}; 193f4a2713aSLionel Sambuc 194f4a2713aSLionel Sambucstruct X : Empty { 195f4a2713aSLionel Sambuc int array[10]; 196f4a2713aSLionel Sambuc}; 197f4a2713aSLionel Sambuc 198f4a2713aSLionel Sambucstruct Y : Empty { 199f4a2713aSLionel Sambuc X vec; 200f4a2713aSLionel Sambuc}; 201f4a2713aSLionel Sambuc 202f4a2713aSLionel Sambuc// CHECK: @g8 = constant [14 x i8] c"{Y={X=[10i]}}\00" 203f4a2713aSLionel Sambucextern const char g8[] = @encode(Y); 204f4a2713aSLionel Sambuc 205f4a2713aSLionel Sambuc 206f4a2713aSLionel Sambucclass dynamic_class { 207f4a2713aSLionel Sambucpublic: 208f4a2713aSLionel Sambuc virtual ~dynamic_class(); 209f4a2713aSLionel Sambuc}; 210f4a2713aSLionel Sambuc@interface has_dynamic_class_ivar 211f4a2713aSLionel Sambuc@end 212f4a2713aSLionel Sambuc@implementation has_dynamic_class_ivar { 213f4a2713aSLionel Sambuc dynamic_class dynamic_class_ivar; 214f4a2713aSLionel Sambuc} 215f4a2713aSLionel Sambuc@end 216*0a6a1f1dSLionel Sambuc// CHECK: private global [41 x i8] c"{dynamic_class=\22_vptr$dynamic_class\22^^?}\00" 217f4a2713aSLionel Sambuc 218f4a2713aSLionel Sambucnamespace PR17142 { 219f4a2713aSLionel Sambuc struct A { virtual ~A(); }; 220f4a2713aSLionel Sambuc struct B : virtual A { int y; }; 221f4a2713aSLionel Sambuc struct C { virtual ~C(); int z; }; 222f4a2713aSLionel Sambuc struct D : C, B { int a; }; 223f4a2713aSLionel Sambuc struct E : D {}; 224f4a2713aSLionel Sambuc // CHECK: @_ZN7PR171421xE = constant [14 x i8] c"{E=^^?i^^?ii}\00" 225f4a2713aSLionel Sambuc extern const char x[] = @encode(E); 226f4a2713aSLionel Sambuc} 227