brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · b07e9e9 Raw
193 lines · plain
1// RUN: %clang_cc1 -Wno-error=return-type -triple i686-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s2// RUN: FileCheck < %t %s3//4// CHECK: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant [16 x i8] c"v12@0:4[3[4@]]8\00"5 6@class Int1;7 8struct Innermost {9  unsigned char a, b;10};11 12@interface Int1 {13  signed char a, b;14  struct Innermost *innermost;15}16@end17 18@implementation Int119@end20 21@interface Base22{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;36}37@end38 39@interface Derived: Base40{41    char d;42    int _field3: 6;43}44@end45 46@implementation Base47@end48 49@implementation Derived50@end51 52@interface B1 53{54    struct objc_class *isa;55    Int1 *sBase;56    char c;57}58@end59 60@implementation B161@end62 63@interface Test 64{65	int ivar;66         __attribute__((objc_gc(weak))) SEL selector;67}68-(void) test3: (Test*  [3] [4])b ; 69- (SEL**) meth : (SEL) arg : (SEL*****) arg1 : (SEL*)arg2 : (SEL**) arg3;70@end71 72@implementation Test73-(void) test3: (Test* [3] [4])b {}74- (SEL**) meth : (SEL) arg : (SEL*****) arg1 : (SEL*)arg2 : (SEL**) arg3 {}75@end76 77struct S { int iS; };78 79@interface Object80{81 Class isa;82}83@end84typedef Object MyObj;85 86int main(void)87{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);93}94 95// CHECK: @g0 ={{.*}} constant [15 x i8] c"{Innermost=CC}\00"96const char g0[] = @encode(struct Innermost);97 98// CHECK: @g1 ={{.*}} constant [38 x i8] c"{Derived=#ib32b8b3b8sb16b8b8b2b8ccb6}\00"99const char g1[] = @encode(Derived);100 101// CHECK: @g2 ={{.*}} constant [9 x i8] c"{B1=#@c}\00"102const char g2[] = @encode(B1);103 104// CHECK: @g3 ={{.*}} constant [8 x i8] c"r^{S=i}\00"105const char g3[] = @encode(const struct S *);106 107// CHECK: @g4 ={{.*}} constant [6 x i8] c"{S=i}\00"108const char g4[] = @encode(const struct S);109 110// CHECK: @g5 ={{.*}} constant [2 x i8] c"@\00"111const char g5[] = @encode(MyObj * const);112 113////114 115enum Enum1X { one, two, three, four };116 117@interface Base1X {118  unsigned a: 2;119  int b: 3;120  enum Enum1X c: 4;121  unsigned d: 5;122} 123@end124 125@interface Derived1X: Base1X {126  signed e: 5;127  int f: 4;128  enum Enum1X g: 3;129} 130@end131 132@implementation Base1X @end133 134@implementation Derived1X @end135 136// CHECK: @g6 ={{.*}} constant [18 x i8] c"{Base1X=b2b3b4b5}\00"137const char g6[] = @encode(Base1X);138 139// CHECK: @g7 ={{.*}} constant [27 x i8] c"{Derived1X=b2b3b4b5b5b4b3}\00"140const char g7[] = @encode(Derived1X);141 142// CHECK: @g8 ={{.*}} constant [7 x i8] c"{s8=D}\00"143struct s8 {144  long double x;145};146const char g8[] = @encode(struct s8);147 148// CHECK: @g9 ={{.*}} constant [11 x i8] c"{S9=i[0i]}\00"149struct S9 {150  int x;151  int flex[];152};153const char g9[] = @encode(struct S9);154 155struct f156{157  int i;158  struct{} g[4];159  int tt;160};161 162// CHECK: @g10 ={{.*}} constant [14 x i8] c"{f=i[4{?=}]i}\00"163const char g10[] = @encode(struct f);164 165// CHECK: @g11 ={{.*}} constant [2 x i8] c"v\00"166const char g11[] = @encode(void);167 168// PR14628169// CHECK: @g12 ={{.*}} constant [3 x i8] c"Ai\00"170const char g12[] = @encode(_Atomic(int));171 172id test_id = 0;173Class test_class = 0;174const char g13[] = @encode(__typeof__(*test_class));175const char g14[] = @encode(__typeof__(*test_id));176// CHECK: constant [14 x i8] c"{objc_class=}\00"177// CHECK: constant [15 x i8] c"{objc_object=}\00"178 179// CHECK: @g15 ={{.*}} constant [2 x i8] c":\00"180const char g15[] = @encode(SEL);181 182typedef typeof(sizeof(int)) size_t;183size_t strlen(const char *s);184 185// CHECK-LABEL: @test_strlen(186// CHECK: %[[i:.*]] = alloca i32187// CHECK: %[[call:.*]] = call i32 @strlen188// CHECK: store i32 %[[call]], ptr %[[i]]189void test_strlen(void) {190  const char array[] = @encode(int);191  int i = strlen(array);192}193