brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · 927281e Raw
171 lines · plain
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s2// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NF3 4// Most of this test is apparently just verifying that we don't crash.5 6int printf(const char *, ...);7 8@interface Root9@end10 11typedef struct {12  int x, y, z[10];13} MyPoint;14typedef struct {15  float width, height;16} MySize;17 18@interface A : Root19+(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3;20+(float) returnAFloat;21+(double) returnADouble;22+(MyPoint) returnAPoint;23+(void) printThisSize: (MySize) arg0;24+(MySize) returnASize;25 26-(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3;27-(float) returnAFloat;28-(double) returnADouble;29-(MyPoint) returnAPoint;30-(void) printThisSize: (MySize) arg0;31-(MySize) returnASize;32@end33@interface B : A34@end35 36@implementation A37+(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3 {38  printf("(CLASS) theInt: %d, theFloat: %f, theDouble: %f, thePoint: { %d, %d }\n",39         arg0, arg1, arg2, arg3.x, arg3.y);40}41+(float) returnAFloat {42  return 15.;43}44+(double) returnADouble {45  return 25.;46}47+(MyPoint) returnAPoint {48  MyPoint x = { 35, 45 };49  return x;50}51+(void) printThisSize: (MySize) arg0 {52  printf("(CLASS) theSize: { %f, %f }\n",53         arg0.width, arg0.height);54}55+(MySize) returnASize {56  MySize x = { 32, 44 };57  return x;58}59 60-(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3 {61  printf("theInt: %d, theFloat: %f, theDouble: %f, thePoint: { %d, %d }\n",62         arg0, arg1, arg2, arg3.x, arg3.y);63}64-(float) returnAFloat {65  return 10.;66}67-(double) returnADouble {68  return 20.;69}70-(MyPoint) returnAPoint {71  MyPoint x = { 30, 40 };72  return x;73}74-(void) printThisSize: (MySize) arg0 {75  printf("theSize: { %f, %f }\n",76         arg0.width, arg0.height);77}78-(MySize) returnASize {79  MySize x = { 22, 34 };80  return x;81}82@end83 84@implementation B85+(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3 {86  arg3.x *= 2;87  arg3.y *= 2;88  [ super printThisInt: arg0*2 andThatFloat: arg1*2 andADouble: arg2*2 andAPoint: arg3 ];89}90+(void) printThisSize: (MySize) arg0 {91  arg0.width *= 2;92  arg0.height *= 2;93  [ super printThisSize: arg0 ];94}95+(float) returnAFloat {96  return [ super returnAFloat ]*2;97}98+(double) returnADouble {99  return [ super returnADouble ]*2;100}101+(MyPoint) returnAPoint {102  MyPoint x = [ super returnAPoint ];103  x.x *= 2;104  x.y *= 2;105  return x;106}107+(MySize) returnASize {108  MySize x = [ super returnASize ];109  x.width *= 2;110  x.height *= 2;111  return x;112}113 114-(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3 {115  arg3.x *= 2;116  arg3.y *= 2;117  [ super printThisInt: arg0*2 andThatFloat: arg1*2 andADouble: arg2*2 andAPoint: arg3 ];118}119-(void) printThisSize: (MySize) arg0 {120  arg0.width *= 2;121  arg0.height *= 2;122  [ super printThisSize: arg0 ];123}124-(float) returnAFloat {125  return [ super returnAFloat ]*2;126}127-(double) returnADouble {128  return [ super returnADouble ]*2;129}130-(MyPoint) returnAPoint {131  MyPoint x = [ super returnAPoint ];132  x.x *= 2;133  x.y *= 2;134  return x;135}136-(MySize) returnASize {137  MySize x = [ super returnASize ];138  x.width *= 2;139  x.height *= 2;140  return x;141}142-(const float) returnAConstFloat {143  return 5;144}145@end146 147// CHECK:    define{{.*}} void @test0(ptr148// CHECK-NF: define{{.*}} void @test0(ptr149void test0(A *x) {150  // CHECK:         [[X:%.*]] = alloca ptr151  // CHECK-NEXT:    [[POINT:%.*]] = alloca [[POINT_T:%.*]],152  // CHECK:         [[T0:%.*]] = load ptr, ptr [[X]]153  // CHECK:    icmp eq ptr [[T0]], null154  // CHECK-NEXT:    br i1155  // CHECK:         call {{.*}} @objc_msgSend_stret156  // CHECK-NEXT:    br label157  // CHECK:    call void @llvm.memset.p0.i64(ptr align 4 [[POINT]], i8 0, i64 48, i1 false)158  // CHECK-NEXT:    br label159 160  // CHECK-NF:      [[X:%.*]] = alloca ptr161  // CHECK-NF-NEXT: [[POINT:%.*]] = alloca [[POINT_T:%.*]],162  // CHECK-NF:      [[T0:%.*]] = load ptr, ptr [[X]]163  // CHECK-NF: icmp eq ptr [[T0]], null164  // CHECK-NF-NEXT: br i1165  // CHECK-NF:      call {{.*}} @objc_msgSend_stret166  // CHECK-NF-NEXT: br label167  // CHECK-NF: call void @llvm.memset.p0.i64(ptr align 4 [[POINT]], i8 0, i64 48, i1 false)168  // CHECK-NF-NEXT: br label169  MyPoint point = [x returnAPoint];170}171