xref: /aosp_15_r20/external/clang/test/CodeGenCXX/empty-nontrivially-copyable.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -triple armv7-apple-ios -x c++ -emit-llvm -o - %s | FileCheck %s
2*67e74705SXin Li // RUN: %clang_cc1 -triple arm64-apple-ios -x c++ -emit-llvm -o - %s | FileCheck %s
3*67e74705SXin Li 
4*67e74705SXin Li // According to the Itanium ABI (3.1.1), types with non-trivial copy
5*67e74705SXin Li // constructors passed by value should be passed indirectly, with the caller
6*67e74705SXin Li // creating a temporary.
7*67e74705SXin Li 
8*67e74705SXin Li struct Empty;
9*67e74705SXin Li 
10*67e74705SXin Li struct Empty {
11*67e74705SXin Li   Empty(const Empty &e);
12*67e74705SXin Li   bool check();
13*67e74705SXin Li };
14*67e74705SXin Li 
foo(Empty e)15*67e74705SXin Li bool foo(Empty e) {
16*67e74705SXin Li // CHECK: @_Z3foo5Empty(%struct.Empty* %e)
17*67e74705SXin Li // CHECK: call {{.*}} @_ZN5Empty5checkEv(%struct.Empty* %e)
18*67e74705SXin Li   return e.check();
19*67e74705SXin Li }
20*67e74705SXin Li 
caller(Empty & e)21*67e74705SXin Li void caller(Empty &e) {
22*67e74705SXin Li // CHECK: @_Z6callerR5Empty(%struct.Empty* dereferenceable({{[0-9]+}}) %e)
23*67e74705SXin Li // CHECK: call {{.*}} @_ZN5EmptyC1ERKS_(%struct.Empty* [[NEWTMP:%.*]], %struct.Empty*
24*67e74705SXin Li // CHECK: call {{.*}} @_Z3foo5Empty(%struct.Empty* [[NEWTMP]])
25*67e74705SXin Li   foo(e);
26*67e74705SXin Li }
27