xref: /llvm-project/clang/test/CXX/special/class.copy/implicit-move-def.cpp (revision 528499bb44e2229709d3bc6a04c8700c083e65d0)
1 // RUN: %clang_cc1 -emit-llvm -o - -std=c++0x %s | FileCheck -check-prefix=CHECK-ASSIGN %s
2 // RUN: %clang_cc1 -emit-llvm -o - -std=c++0x %s | FileCheck -check-prefix=CHECK-CTOR %s
3 
4 // construct
5 
6 struct E {
7   E();
8   E(E&&);
9 };
10 
11 struct F {
12   F();
13   F(F&&);
14 };
15 
16 struct G {
17   E e;
18 };
19 
20 struct H : G {
21   F l;
22   E m;
23   F ar[2];
24 };
25 
26 void f() {
27   H s;
28   // CHECK: call void @_ZN1HC1EOS_
29   H t(static_cast<H&&>(s));
30 }
31 
32 
33 // assign
34 
35 struct A {
36   A &operator =(A&&);
37 };
38 
39 struct B {
40   B &operator =(B&&);
41 };
42 
43 struct C {
44   A a;
45 };
46 
47 struct D : C {
48   A a;
49   B b;
50   A ar[2];
51 };
52 
53 void g() {
54   D d;
55   // CHECK: call {{.*}} @_ZN1DaSEOS_
56   d = D();
57 }
58 
59 // PR10822
60 struct I {
61   unsigned var[1];
62 };
63 
64 void h() {
65   I i;
66   i = I();
67 }
68 
69 // move assignment ops
70 
71 // CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1DaSEOS_
72 // CHECK-ASSIGN: call {{.*}} @_ZN1CaSEOS_
73 // CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_
74 // CHECK-ASSIGN: call {{.*}} @_ZN1BaSEOS_
75 // array loop
76 // CHECK-ASSIGN: br i1
77 // CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_
78 
79 // CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1IaSEOS_
80 // call void @llvm.memcpy.
81 
82 // CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1CaSEOS_
83 // CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_
84 
85 // move ctors
86 
87 // CHECK-CTOR: define linkonce_odr void @_ZN1HC2EOS_
88 // CHECK-CTOR: call void @_ZN1GC2EOS_
89 // CHECK-CTOR: call void @_ZN1FC1EOS_
90 // CHECK-CTOR: call void @_ZN1EC1EOS_
91 // array loop
92 // CHECK-CTOR: br i1
93 // CHECK-CTOR: call void @_ZN1FC1EOS_
94 
95 // CHECK-CTOR: define linkonce_odr void @_ZN1GC2EOS_
96 // CHECK-CTOR: call void @_ZN1EC1EOS_
97