[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / clang / test / CodeGenCXX / unknown-anytype.cpp
blobade9a6482d75caede418801a9e4e4128b1154ca0
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -funknown-anytype -emit-llvm -o %t %s
2 // RUN: FileCheck -check-prefix COMMON %s < %t
3 // RUN: FileCheck -check-prefix X86_64 %s < %t
4 // RUN: %clang_cc1 -triple i386-apple-darwin10 -funknown-anytype -emit-llvm -o %t %s
5 // RUN: FileCheck -check-prefix COMMON %s < %t
6 // RUN: FileCheck -check-prefix I386 %s < %t
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 if
10 // other platforms do not.
12 int test0() {
13 extern __unknown_anytype test0_any;
14 // COMMON: load i32, ptr @test0_any
15 return (int) test0_any;
18 int test1() {
19 extern __unknown_anytype test1_any();
20 // COMMON: call noundef i32 @_Z9test1_anyv()
21 return (int) test1_any();
24 extern "C" __unknown_anytype test2_any(...);
25 float 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);
31 extern "C" __unknown_anytype test2a_any(...);
32 float 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);
38 float 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);
45 namespace test4 {
46 extern __unknown_anytype test4_any1;
47 extern __unknown_anytype test4_any2;
49 int test() {
50 // COMMON: load i32, ptr @_ZN5test410test4_any1E
51 // COMMON: load i8, ptr @_ZN5test410test4_any2E
52 return (int) test4_any1 + (char) test4_any2;
56 extern "C" __unknown_anytype test5_any();
57 void test5() {
58 // COMMON: call void @test5_any()
59 return (void) test5_any();
62 extern "C" __unknown_anytype test6_any(float *);
63 long test6() {
64 // COMMON: call i64 @test6_any(ptr noundef null)
65 return (long long) test6_any(0);
68 struct Test7 {
69 ~Test7();
71 extern "C" __unknown_anytype test7_any(int);
72 Test7 test7() {
73 // COMMON: call void @test7_any(ptr dead_on_unwind writable sret({{%.*}}) align 1 {{%.*}}, i32 noundef 5)
74 return (Test7) test7_any(5);
77 struct Test8 {
78 __unknown_anytype foo();
79 __unknown_anytype foo(int);
81 void test();
83 void 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);
94 void 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);
106 extern "C" __unknown_anytype test9_foo;
107 void *test9() {
108 // COMMON: ret ptr @test9_foo
109 return (int*) &test9_foo;
112 // Don't explode on this.
113 extern "C" __unknown_anytype test10_any(...);
114 void test10() {
115 (void) test10_any(), (void) test10_any();
118 extern "C" __unknown_anytype malloc(...);
119 void 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)