1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
3 extern "C" int printf(...);
15 N(N
const & arg
){this->iN
= arg
.iN
; }
24 // CHECK-LABEL: define linkonce_odr void @_ZN1XC1ERKS_(ptr {{[^,]*}} %this, ptr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0) unnamed_addr
25 struct X
: M
, N
, P
{ // ...
26 X() : f1(1.0), d1(2.0), i1(3), name("HELLO"), bf1(0xff), bf2(0xabcd),
27 au_i1(1234), au1_4("MASKED") {}
30 printf("iM = %d iN = %d, m1.iM = %d\n", iM
, iN
, m1
.iM
);
31 printf("im = %d p0.iP = %d, p1.iP = %d\n", iP
, p0
.iP
, p1
.iP
);
32 printf("f1 = %f d1 = %f i1 = %d name(%s) \n", f1
, d1
, i1
, name
);
33 printf("bf1 = %x bf2 = %x\n", bf1
, bf2
);
34 printf("au_i2 = %d\n", au_i2
);
35 printf("au1_1 = %s\n", au1_1
);
46 _Complex
float complex;
61 // class with user-defined copy constructor.
64 S(const S
& arg
) { *this = arg
; }
68 // class with trivial copy constructor.
79 for (unsigned i
= 0; i
< 3; i
++)
80 for (unsigned j
= 0; j
< 4; j
++)
81 for (unsigned k
= 0; k
< 2; k
++)
82 printf("ARR_S[%d][%d][%d] = %d\n", i
,j
,k
, ARR_S
[i
][j
][k
].iS
);
83 for (unsigned i
= 0; i
< 3; i
++)
84 for (unsigned k
= 0; k
< 2; k
++)
85 printf("ARR_I[%d][%d] = %d\n", i
,k
, ARR_I
[i
][k
].iI
);
110 void f(const B
&b1
) {
125 A(const A
&other
, const T
&t
= T(), const T
& t2
= T());
134 // Force the copy constructor to be synthesized.
139 // CHECK: define linkonce_odr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_ZN12rdar138169401AaSERKS0_(
140 // CHECK: [[THIS:%.*]] = load ptr, ptr
141 // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[A:%.*]], ptr [[THIS]], i32 0, i32 1
142 // CHECK-NEXT: [[OTHER:%.*]] = load ptr, ptr
143 // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[A]], ptr [[OTHER]], i32 0, i32 1
144 // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[T0]], ptr align 8 [[T2]], i64 8, i1 false)
145 // CHECK-NEXT: ret ptr [[THIS]]
147 // CHECK-LABEL: define linkonce_odr void @_ZN6PR66281BC2ERKS0_(ptr {{[^,]*}} %this, ptr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0) unnamed_addr
148 // CHECK: call void @_ZN6PR66281TC1Ev
149 // CHECK: call void @_ZN6PR66281TC1Ev
150 // CHECK: call void @_ZN6PR66281AC2ERKS0_RKNS_1TES5_
151 // CHECK: call void @_ZN6PR66281TD1Ev
152 // CHECK: call void @_ZN6PR66281TD1Ev
153 // CHECK: call void @_ZN6PR66281TC1Ev
154 // CHECK: call void @_ZN6PR66281TC1Ev
155 // CHECK: call void @_ZN6PR66281AC1ERKS0_RKNS_1TES5_
156 // CHECK: call void @_ZN6PR66281TD1Ev
157 // CHECK: call void @_ZN6PR66281TD1Ev
158 // CHECK: call void @_ZN6PR66281TC1Ev
159 // CHECK: call void @_ZN6PR66281TC1Ev
160 // CHECK: call void @_ZN6PR66281AC1ERKS0_RKNS_1TES5_
161 // CHECK: call void @_ZN6PR66281TD1Ev
162 // CHECK: call void @_ZN6PR66281TD1Ev
164 // CHECK-LABEL: define linkonce_odr void @_ZN12rdar138169401AC2ERKS0_(
165 // CHECK: [[THIS:%.*]] = load ptr, ptr
166 // CHECK-NEXT: store ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTVN12rdar138169401AE, i32 0, inrange i32 0, i32 2), ptr [[THIS]]
167 // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[A]], ptr [[THIS]], i32 0, i32 1
168 // CHECK-NEXT: [[OTHER:%.*]] = load ptr, ptr
169 // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[A]], ptr [[OTHER]], i32 0, i32 1
170 // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[T0]], ptr align 8 [[T2]], i64 8, i1 false)
171 // CHECK-NEXT: ret void
174 // Test above because things get weirdly re-ordered.
175 namespace rdar13816940
{
178 unsigned short a
: 1;
184 A x
= a
; // force copy constructor into existence
185 x
= a
; // also force the copy assignment operator