1 // 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 i686-windows | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-WINDOWS
3 // RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-windows | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-WINDOWS
23 friend void operator->*(C
, B
);
25 friend void operator<<(C
, B
);
26 friend void operator>>(C
, B
);
32 friend void operator+=(C
, B
);
35 friend void operator,(C
, B
);
39 friend void operator&&(C
, B
);
40 friend void operator||(C
, B
);
45 int A::*make_mem_ptr_a();
46 void (A::*make_mem_fn_ptr_a())();
55 // CHECK-LABEL: define {{.*}}@{{.*}}postfix_before_args{{.*}}(
56 void postfix_before_args() {
57 // CHECK: call {{.*}}@{{.*}}get_f{{.*}}(
58 // CHECK-ITANIUM: call {{.*}}@_ZN1AC1Ev(
59 // CHECK-WINDOWS: call {{.*}}@"??0A@@Q{{AE|EAA}}@XZ"(
60 // CHECK: call {{.*}}%{{.*}}(
63 // CHECK: call {{.*}}@{{.*}}side_effect{{.*}}(
64 // CHECK-ITANIUM: call {{.*}}@_ZN1AC1Ev(
65 // CHECK-WINDOWS: call {{.*}}@"??0A@@Q{{AE|EAA}}@XZ"(
66 // CHECK: call {{.*}}@{{.*}}callee{{.*}}(
67 (side_effect(), callee
)(A
{});
72 // CHECK-LABEL: define {{.*}}@{{.*}}dot_lhs_before_rhs{{.*}}(
73 void dot_lhs_before_rhs() {
74 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
75 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
76 // CHECK: call {{.*}}@{{.*}}a_member_f{{.*}}(
77 make_a().a_member_f(make_b());
79 // CHECK: call {{.*}}@{{.*}}make_a_ptr{{.*}}(
80 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
81 // CHECK: call {{.*}}@{{.*}}a_member_f{{.*}}(
82 make_a_ptr()->a_member_f(make_b());
84 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
85 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
86 // CHECK: call {{.*}}@{{.*}}a_member_f{{.*}}(
87 make_c()->a_member_f(make_b());
92 // CHECK-LABEL: define {{.*}}@{{.*}}array_lhs_before_rhs{{.*}}(
93 void array_lhs_before_rhs() {
95 extern int get_index();
97 // CHECK: call {{.*}}@{{.*}}get_arr{{.*}}(
98 // CHECK: call {{.*}}@{{.*}}get_index{{.*}}(
99 get_arr()[get_index()] = 0;
101 // CHECK: call {{.*}}@{{.*}}get_index{{.*}}(
102 // CHECK: call {{.*}}@{{.*}}get_arr{{.*}}(
103 get_index()[get_arr()] = 0;
105 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
106 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
110 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
111 // CHECK: call {{.*}}@{{.*}}get_index{{.*}}(
113 make_c()[get_index()] = 0;
115 // CHECK: call {{.*}}@{{.*}}get_index{{.*}}(
116 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
118 get_index()[make_c()] = 0;
123 void *operator new(decltype(sizeof(0)), C
);
125 // CHECK-LABEL: define {{.*}}@{{.*}}alloc_before_init{{.*}}(
126 void alloc_before_init() {
127 struct Q
{ Q(A
) {} };
128 // CHECK-ITANIUM: call {{.*}}@_Znw{{.*}}(
129 // CHECK-WINDOWS: call {{.*}}@"??2@YAP{{EAX_K|AXI}}@Z"(
130 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
131 delete new Q(make_a());
133 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
134 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
135 new (make_c()) Q(make_a());
140 // CHECK-LABEL: define {{.*}}@{{.*}}dotstar_lhs_before_rhs{{.*}}(
141 int dotstar_lhs_before_rhs() {
142 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
143 // CHECK: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}(
144 int a
= make_a().*make_mem_ptr_a();
146 // CHECK: call {{.*}}@{{.*}}make_a_ptr{{.*}}(
147 // CHECK: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}(
148 int b
= make_a_ptr()->*make_mem_ptr_a();
150 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
151 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
154 // FIXME: For MS ABI, the order of destruction of parameters here will not be
155 // reverse construction order (parameters are destroyed left-to-right in the
156 // callee). That sadly seems unavoidable; the rules are not implementable as
157 // specified. If we changed parameter destruction order for these functions
158 // to right-to-left, we could make the destruction order match for all cases
159 // other than indirect calls, but we can't completely avoid the problem.
161 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
162 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
165 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
166 // CHECK: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}(
168 (make_a().*make_mem_fn_ptr_a())();
170 // CHECK: call {{.*}}@{{.*}}make_a_ptr{{.*}}(
171 // CHECK: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}(
173 (make_a_ptr()->*make_mem_fn_ptr_a())();
180 // CHECK-LABEL: define {{.*}}@{{.*}}assign_rhs_before_lhs{{.*}}(
181 void assign_rhs_before_lhs() {
182 extern int &lhs_ref(), rhs();
184 // CHECK: call {{.*}}@{{.*}}rhs{{.*}}(
185 // CHECK: call {{.*}}@{{.*}}lhs_ref{{.*}}(
188 // CHECK: call {{.*}}@{{.*}}rhs{{.*}}(
189 // CHECK: call {{.*}}@{{.*}}lhs_ref{{.*}}(
192 // CHECK: call {{.*}}@{{.*}}rhs{{.*}}(
193 // CHECK: call {{.*}}@{{.*}}lhs_ref{{.*}}(
196 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
197 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
200 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
201 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
202 make_c() += make_a();
204 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
205 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
206 make_c() += make_b();
210 // CHECK-LABEL: define {{.*}}@{{.*}}shift_lhs_before_rhs{{.*}}(
211 void shift_lhs_before_rhs() {
212 extern int lhs(), rhs();
214 // CHECK: call {{.*}}@{{.*}}lhs{{.*}}(
215 // CHECK: call {{.*}}@{{.*}}rhs{{.*}}(
216 (void)(lhs() << rhs());
218 // CHECK: call {{.*}}@{{.*}}lhs{{.*}}(
219 // CHECK: call {{.*}}@{{.*}}rhs{{.*}}(
220 (void)(lhs() >> rhs());
222 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
223 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
224 make_c() << make_a();
226 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
227 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
228 make_c() >> make_a();
230 // FIXME: This is not correct for Windows ABIs, see above.
231 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
232 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
233 make_c() << make_b();
235 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
236 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
237 make_c() >> make_b();
241 // CHECK-LABEL: define {{.*}}@{{.*}}comma_lhs_before_rhs{{.*}}(
242 void comma_lhs_before_rhs() {
243 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
244 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
247 // FIXME: This is not correct for Windows ABIs, see above.
248 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
249 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
253 // CHECK-LABEL: define {{.*}}@{{.*}}andor_lhs_before_rhs{{.*}}(
254 void andor_lhs_before_rhs() {
255 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
256 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
257 make_c() && make_a();
259 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
260 // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
261 make_c() || make_a();
263 // FIXME: This is not correct for Windows ABIs, see above.
264 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
265 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
266 make_c() && make_b();
268 // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
269 // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
270 make_c() || make_b();