brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · ade9a64 Raw
125 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -funknown-anytype -emit-llvm -o %t %s2// RUN: FileCheck -check-prefix COMMON %s < %t3// RUN: FileCheck -check-prefix X86_64 %s < %t4// RUN: %clang_cc1 -triple i386-apple-darwin10 -funknown-anytype -emit-llvm -o %t %s5// RUN: FileCheck -check-prefix COMMON %s < %t6// RUN: FileCheck -check-prefix I386 %s < %t7 8// x86-64 is the special case here because of its variadic convention.9// We want to ensure that it always uses a variadic convention even if10// other platforms do not.11 12int test0() {13  extern __unknown_anytype test0_any;14  // COMMON: load i32, ptr @test0_any15  return (int) test0_any;16}17 18int test1() {19  extern __unknown_anytype test1_any();20  // COMMON: call noundef i32 @_Z9test1_anyv()21  return (int) test1_any();22}23 24extern "C" __unknown_anytype test2_any(...);25float test2() {26  // X86_64: call float (double, ...) @test2_any(double {{[^,]+}})27  // I386: call float (double, ...) @test2_any(double {{[^,]+}})28  return (float) test2_any(0.5f);29}30 31extern "C" __unknown_anytype test2a_any(...);32float test2a() {33  // X86_64: call float (float, ...) @test2a_any(float {{[^,]+}})34  // I386: call float (float, ...) @test2a_any(float {{[^,]+}})35  return (float) test2a_any((float) 0.5f);36}37 38float test3() {39  extern __unknown_anytype test3_any;40  // COMMON: [[FN:%.*]] = load ptr, ptr @test3_any,41  // COMMON: call noundef float [[FN]](i32 noundef 5)42  return ((float(*)(int)) test3_any)(5);43}44 45namespace test4 {46  extern __unknown_anytype test4_any1;47  extern __unknown_anytype test4_any2;48 49  int test() {50    // COMMON: load i32, ptr @_ZN5test410test4_any1E51    // COMMON: load i8, ptr @_ZN5test410test4_any2E52    return (int) test4_any1 + (char) test4_any2;53  }54}55 56extern "C" __unknown_anytype test5_any();57void test5() {58  // COMMON: call void @test5_any()59  return (void) test5_any();60}61 62extern "C" __unknown_anytype test6_any(float *);63long test6() {64  // COMMON: call i64 @test6_any(ptr noundef null)65  return (long long) test6_any(0);66}67 68struct Test7 {69  ~Test7();70};71extern "C" __unknown_anytype test7_any(int);72Test7 test7() {73  // COMMON: call void @test7_any(ptr dead_on_unwind writable sret({{%.*}}) align 1 {{%.*}}, i32 noundef 5)74  return (Test7) test7_any(5);75}76 77struct Test8 {78  __unknown_anytype foo();79  __unknown_anytype foo(int);80 81  void test();82};83void Test8::test() {84  float f;85  // COMMON: call noundef i32 @_ZN5Test83fooEv(86  f = (int) foo();87  // COMMON: call noundef i32 @_ZN5Test83fooEi(88  f = (int) foo(5);89  // COMMON: call noundef i32 @_ZN5Test83fooEv(90  f = (float) this->foo();91  // COMMON: call noundef i32 @_ZN5Test83fooEi(92  f = (float) this->foo(5);93}94void test8(Test8 *p) {95  double d;96  // COMMON: call noundef i32 @_ZN5Test83fooEv(97  d = (double) p->foo();98  // COMMON: call noundef i32 @_ZN5Test83fooEi(99  d = (double) p->foo(5);100  // COMMON: call noundef i32 @_ZN5Test83fooEv(101  d = (bool) (*p).foo();102  // COMMON: call noundef i32 @_ZN5Test83fooEi(103  d = (bool) (*p).foo(5);104}105 106extern "C" __unknown_anytype test9_foo;107void *test9() {108  // COMMON: ret ptr @test9_foo109  return (int*) &test9_foo;110}111 112// Don't explode on this.113extern "C" __unknown_anytype test10_any(...);114void test10() {115  (void) test10_any(), (void) test10_any();116}117 118extern "C" __unknown_anytype malloc(...);119void test11() {120  void *s = (void*)malloc(12);121  // COMMON: call ptr (i32, ...) @malloc(i32 noundef 12)122  void *d = (void*)malloc(435);123  // COMMON: call ptr (i32, ...) @malloc(i32 noundef 435)124}125