blob: 3531891d383cbbb54947e8b7be191d2702d239fe [file] [log] [blame]
Richard Smith9e67b992016-09-26 23:49:47 +00001// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple %itanium_abi_triple | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ITANIUM
2// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple %ms_abi_triple | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-WINDOWS
3
4struct B;
5struct A {
6 A();
7 A(const A&);
8
9 void operator[](B b);
10
11 int a_member_f(B);
12};
13struct B {
14 B();
15 ~B();
16};
17
18struct C {
19 operator int *();
20 A *operator->();
21 void operator->*(B);
22
23 friend void operator<<(C, B);
24 friend void operator>>(C, B);
25 void operator<<(A);
26 void operator>>(A);
27
28 void operator=(B);
29 void operator+=(B);
30};
31
32A make_a();
33A *make_a_ptr();
34int A::*make_mem_ptr_a();
35void (A::*make_mem_fn_ptr_a())();
36B make_b();
37C make_c();
38void side_effect();
39
40void callee(A);
41void (*get_f())(A);
42
43
44// CHECK-LABEL: define {{.*}}@{{.*}}postfix_before_args{{.*}}(
45void postfix_before_args() {
46 // CHECK: call {{.*}}@{{.*}}get_f{{.*}}(
47 // CHECK-ITANIUM: call {{.*}}@_ZN1AC1Ev(
48 // CHECK-WINDOWS: call {{.*}}@"\01??0A@@QEAA@XZ"(
49 // CHECK: call {{.*}}%{{.*}}(
50 get_f()(A{});
51
52 // CHECK: call {{.*}}@{{.*}}side_effect{{.*}}(
53 // CHECK-ITANIUM: call {{.*}}@_ZN1AC1Ev(
54 // CHECK-WINDOWS: call {{.*}}@"\01??0A@@QEAA@XZ"(
55 // CHECK: call {{.*}}@{{.*}}callee{{.*}}(
56 (side_effect(), callee)(A{});
57// CHECK: }
58}
59
60
61// CHECK-LABEL: define {{.*}}@{{.*}}dot_lhs_before_rhs{{.*}}(
62void dot_lhs_before_rhs() {
63 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
64 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
65 // CHECK: call {{.*}}@{{.*}}a_member_f{{.*}}(
66 make_a().a_member_f(make_b());
67
68 // CHECK: call {{.*}}@{{.*}}make_a_ptr{{.*}}(
69 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
70 // CHECK: call {{.*}}@{{.*}}a_member_f{{.*}}(
71 make_a_ptr()->a_member_f(make_b());
72
73 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
74 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
75 // CHECK: call {{.*}}@{{.*}}a_member_f{{.*}}(
76 make_c()->a_member_f(make_b());
77// CHECK: }
78}
79
80
81// CHECK-LABEL: define {{.*}}@{{.*}}array_lhs_before_rhs{{.*}}(
82void array_lhs_before_rhs() {
83 int (&get_arr())[10];
84 extern int get_index();
85
86 // CHECK: call {{.*}}@{{.*}}get_arr{{.*}}(
87 // CHECK: call {{.*}}@{{.*}}get_index{{.*}}(
88 get_arr()[get_index()] = 0;
89
90 // CHECK: call {{.*}}@{{.*}}get_index{{.*}}(
91 // CHECK: call {{.*}}@{{.*}}get_arr{{.*}}(
92 get_index()[get_arr()] = 0;
93
94 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
95 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
96 // CHECK: call
97 make_a()[make_b()];
98
99 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
100 // CHECK: call {{.*}}@{{.*}}get_index{{.*}}(
101 // CHECK: call
102 make_c()[get_index()] = 0;
103
104 // CHECK: call {{.*}}@{{.*}}get_index{{.*}}(
105 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
106 // CHECK: call
107 get_index()[make_c()] = 0;
108// CHECK: }
109}
110
111
112void *operator new(decltype(sizeof(0)), C);
113
114// CHECK-LABEL: define {{.*}}@{{.*}}alloc_before_init{{.*}}(
115void alloc_before_init() {
116 struct Q { Q(A) {} };
117 // CHECK-ITANIUM: call {{.*}}@_Znw{{.*}}(
118 // CHECK-WINDOWS: call {{.*}}@"\01??2@YAPEAX_K@Z"(
119 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
120 delete new Q(make_a());
121
122 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
123 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
124 new (make_c()) Q(make_a());
125// CHECK: }
126}
127
128#if 0
129// CHECKDISABLED-LABEL: define {{.*}}@{{.*}}dotstar_lhs_before_rhs{{.*}}(
130int dotstar_lhs_before_rhs() {
131 // CHECKDISABLED: call {{.*}}@{{.*}}make_a{{.*}}(
132 // CHECKDISABLED: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}(
133 int a = make_a().*make_mem_ptr_a();
134
135 // CHECKDISABLED: call {{.*}}@{{.*}}make_a_ptr{{.*}}(
136 // CHECKDISABLED: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}(
137 int b = make_a_ptr()->*make_mem_ptr_a();
138
139 // CHECKDISABLED: call {{.*}}@{{.*}}make_c{{.*}}(
140 // CHECKDISABLED: call {{.*}}@{{.*}}make_b{{.*}}(
141 make_c()->*make_b();
142
143 // CHECKDISABLED: call {{.*}}@{{.*}}make_a{{.*}}(
144 // CHECKDISABLED: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}(
145 // CHECKDISABLED: call
146 (make_a().*make_mem_fn_ptr_a())();
147
148 // CHECKDISABLED: call {{.*}}@{{.*}}make_a_ptr{{.*}}(
149 // CHECKDISABLED: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}(
150 // CHECKDISABLED: call
151 (make_a_ptr()->*make_mem_fn_ptr_a())();
152
153 return a + b;
154// CHECKDISABLED: }
155}
156#endif
157#if 0
158// CHECKDISABLED-LABEL: define {{.*}}@{{.*}}assign_lhs_before_rhs{{.*}}(
159void assign_rhs_before_lhs() {
160 extern int &lhs_ref(), rhs();
161
162 // CHECKDISABLED: call {{.*}}@{{.*}}rhs{{.*}}(
163 // CHECKDISABLED: call {{.*}}@{{.*}}lhs_ref{{.*}}(
164 lhs_ref() = rhs();
165
166 // CHECKDISABLED: call {{.*}}@{{.*}}rhs{{.*}}(
167 // CHECKDISABLED: call {{.*}}@{{.*}}lhs_ref{{.*}}(
168 lhs_ref() += rhs();
169
170 // CHECKDISABLED: call {{.*}}@{{.*}}rhs{{.*}}(
171 // CHECKDISABLED: call {{.*}}@{{.*}}lhs_ref{{.*}}(
172 lhs_ref() %= rhs();
173
174 // CHECKDISABLED: call {{.*}}@{{.*}}make_b{{.*}}(
175 // CHECKDISABLED: call {{.*}}@{{.*}}make_c{{.*}}(
176 make_c() = make_b();
177
178 // CHECKDISABLED: call {{.*}}@{{.*}}make_b{{.*}}(
179 // CHECKDISABLED: call {{.*}}@{{.*}}make_c{{.*}}(
180 make_c() += make_b();
181// CHECKDISABLED: }
182}
183#endif
184#if 0
185// CHECKDISABLED-LABEL: define {{.*}}@{{.*}}shift_lhs_before_rhs{{.*}}(
186void shift_lhs_before_rhs() {
187 extern int lhs(), rhs();
188
189 // CHECKDISABLED: call {{.*}}@{{.*}}lhs{{.*}}(
190 // CHECKDISABLED: call {{.*}}@{{.*}}rhs{{.*}}(
191 (void)(lhs() << rhs());
192
193 // CHECKDISABLED: call {{.*}}@{{.*}}lhs{{.*}}(
194 // CHECKDISABLED: call {{.*}}@{{.*}}rhs{{.*}}(
195 (void)(lhs() >> rhs());
196
197 // CHECKDISABLED: call {{.*}}@{{.*}}make_c{{.*}}(
198 // CHECKDISABLED: call {{.*}}@{{.*}}make_a{{.*}}(
199 make_c() << make_a();
200
201 // CHECKDISABLED: call {{.*}}@{{.*}}make_c{{.*}}(
202 // CHECKDISABLED: call {{.*}}@{{.*}}make_a{{.*}}(
203 make_c() >> make_a();
204
205 // CHECKDISABLED: call {{.*}}@{{.*}}make_c{{.*}}(
206 // CHECKDISABLED: call {{.*}}@{{.*}}make_b{{.*}}(
207 make_c() << make_b();
208
209 // CHECKDISABLED: call {{.*}}@{{.*}}make_c{{.*}}(
210 // CHECKDISABLED: call {{.*}}@{{.*}}make_b{{.*}}(
211 make_c() >> make_b();
212// CHECKDISABLED: }
213}
214#endif