StmtPrinter: factor out arg printing code to PrintCallArgs
[clang.git] / test / CodeGenObjC / encode-test.m
blob24a90a0b4b998fa1b24b6a01d466d4c546488b8e
1 // RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o %t %s
2 // RUN: FileCheck < %t %s
3 //
4 // CHECK: @"\01L_OBJC_METH_VAR_TYPE_34" = internal global [16 x i8] c"v12@0:4[3[4@]]8\00"
6 @class Int1;
8 struct Innermost {
9   unsigned char a, b;
12 @interface Int1 {
13   signed char a, b;
14   struct Innermost *innermost;
16 @end
18 @implementation Int1
19 @end
21 @interface Base
23     struct objc_class *isa;
24     int full;
25     int full2: 32;
26     int _refs: 8;
27     int field2: 3;
28     unsigned f3: 8;
29     short cc;
30     unsigned g: 16;
31     int r2: 8;
32     int r3: 8;
33     int r4: 2;
34     int r5: 8;
35     char c;
37 @end
39 @interface Derived: Base
41     char d;
42     int _field3: 6;
44 @end
46 @implementation Base
47 @end
49 @implementation Derived
50 @end
52 @interface B1 
54     struct objc_class *isa;
55     Int1 *sBase;
56     char c;
58 @end
60 @implementation B1
61 @end
63 @interface Test 
65         int ivar;
66          __attribute__((objc_gc(weak))) SEL selector;
68 -(void) test3: (Test*  [3] [4])b ; 
69 - (SEL**) meth : (SEL) arg : (SEL*****) arg1 : (SEL*)arg2 : (SEL**) arg3;
70 @end
72 @implementation Test
73 -(void) test3: (Test* [3] [4])b {}
74 - (SEL**) meth : (SEL) arg : (SEL*****) arg1 : (SEL*)arg2 : (SEL**) arg3 {}
75 @end
77 struct S { int iS; };
79 @interface Object
81  Class isa;
83 @end
84 typedef Object MyObj;
86 int main()
88         const char *en = @encode(Derived);
89         const char *eb = @encode(B1);
90         const char *es = @encode(const struct S *);
91         const char *ec = @encode(const struct S);
92         const char *ee = @encode(MyObj *const);
95 // CHECK: @g0 = constant [15 x i8] c"{Innermost=CC}\00"
96 const char g0[] = @encode(struct Innermost);
98 // CHECK: @g1 = constant [38 x i8] c"{Derived=#ib32b8b3b8sb16b8b8b2b8ccb6}\00"
99 const char g1[] = @encode(Derived);
101 // CHECK: @g2 = constant [9 x i8] c"{B1=#@c}\00"
102 const char g2[] = @encode(B1);
104 // CHECK: @g3 = constant [8 x i8] c"r^{S=i}\00"
105 const char g3[] = @encode(const struct S *);
107 // CHECK: @g4 = constant [6 x i8] c"{S=i}\00"
108 const char g4[] = @encode(const struct S);
110 // CHECK: @g5 = constant [12 x i8] c"^{Object=#}\00"
111 const char g5[] = @encode(MyObj * const);
113 ////
115 enum Enum1X { one, two, three, four };
117 @interface Base1X {
118   unsigned a: 2;
119   int b: 3;
120   enum Enum1X c: 4;
121   unsigned d: 5;
123 @end
125 @interface Derived1X: Base1X {
126   signed e: 5;
127   int f: 4;
128   enum Enum1X g: 3;
130 @end
132 @implementation Base1X @end
134 @implementation Derived1X @end
136 // CHECK: @g6 = constant [18 x i8] c"{Base1X=b2b3b4b5}\00"
137 const char g6[] = @encode(Base1X);
139 // CHECK: @g7 = constant [27 x i8] c"{Derived1X=b2b3b4b5b5b4b3}\00"
140 const char g7[] = @encode(Derived1X);
142 // CHECK: @g8 = constant [7 x i8] c"{s8=D}\00"
143 struct s8 {
144   long double x;
146 const char g8[] = @encode(struct s8);