blob: 94023cbc1d7be59009aa12cff8dde05809f0e7aa [file] [log] [blame]
Richard Smith9ca5c422011-10-13 22:29:44 +00001// RUN: %clang_cc1 -emit-llvm -o - -std=c++11 %s | FileCheck -check-prefix=CHECK-ASSIGN %s
2// RUN: %clang_cc1 -emit-llvm -o - -std=c++11 %s | FileCheck -check-prefix=CHECK-CTOR %s
Sebastian Redl22653ba2011-08-30 19:58:05 +00003
4// construct
5
6struct E {
7 E();
8 E(E&&);
9};
10
11struct F {
12 F();
13 F(F&&);
14};
15
16struct G {
17 E e;
18};
19
20struct H : G {
21 F l;
22 E m;
23 F ar[2];
24};
25
26void f() {
27 H s;
28 // CHECK: call void @_ZN1HC1EOS_
29 H t(static_cast<H&&>(s));
30}
31
32
33// assign
34
35struct A {
36 A &operator =(A&&);
37};
38
39struct B {
40 B &operator =(B&&);
41};
42
43struct C {
44 A a;
45};
46
47struct D : C {
48 A a;
49 B b;
50 A ar[2];
51};
52
53void g() {
54 D d;
55 // CHECK: call {{.*}} @_ZN1DaSEOS_
56 d = D();
57}
58
Douglas Gregor528499b2011-09-01 02:09:07 +000059// PR10822
60struct I {
61 unsigned var[1];
62};
63
Douglas Gregor146b8e92011-09-06 16:26:56 +000064// CHECK: define void @_Z1hv() nounwind {
Douglas Gregor528499b2011-09-01 02:09:07 +000065void h() {
66 I i;
Douglas Gregor146b8e92011-09-06 16:26:56 +000067 // CHECK: call void @llvm.memcpy.
Douglas Gregor528499b2011-09-01 02:09:07 +000068 i = I();
Douglas Gregor146b8e92011-09-06 16:26:56 +000069 // CHECK-NEXT: ret void
70}
71
72// PR10860
73struct Empty { };
74struct VirtualWithEmptyBase : Empty {
75 virtual void f();
76};
77
78// CHECK: define void @_Z25move_VirtualWithEmptyBaseR20VirtualWithEmptyBaseS0_
79void move_VirtualWithEmptyBase(VirtualWithEmptyBase &x, VirtualWithEmptyBase &y) {
80 // CHECK: call {{.*}} @_ZN20VirtualWithEmptyBaseaSEOS_
81 x = static_cast<VirtualWithEmptyBase&&>(y);
82 // CHECK-NEXT: ret void
Douglas Gregor528499b2011-09-01 02:09:07 +000083}
Sebastian Redl22653ba2011-08-30 19:58:05 +000084
85// move assignment ops
86
Douglas Gregor528499b2011-09-01 02:09:07 +000087// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1DaSEOS_
88// CHECK-ASSIGN: call {{.*}} @_ZN1CaSEOS_
89// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_
90// CHECK-ASSIGN: call {{.*}} @_ZN1BaSEOS_
Sebastian Redl22653ba2011-08-30 19:58:05 +000091// array loop
Douglas Gregor528499b2011-09-01 02:09:07 +000092// CHECK-ASSIGN: br i1
93// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_
Sebastian Redl22653ba2011-08-30 19:58:05 +000094
Douglas Gregor146b8e92011-09-06 16:26:56 +000095// VirtualWithEmptyBase move assignment operatpr
96// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN20VirtualWithEmptyBaseaSEOS_
97// CHECK-ASSIGN: store
98// CHECK-ASSIGN-NEXT: store
99// CHECK-NOT: call
100// CHECK: ret
Sebastian Redl22653ba2011-08-30 19:58:05 +0000101
Douglas Gregor528499b2011-09-01 02:09:07 +0000102// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1CaSEOS_
103// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_
Sebastian Redl22653ba2011-08-30 19:58:05 +0000104
105// move ctors
106
Douglas Gregor528499b2011-09-01 02:09:07 +0000107// CHECK-CTOR: define linkonce_odr void @_ZN1HC2EOS_
108// CHECK-CTOR: call void @_ZN1GC2EOS_
109// CHECK-CTOR: call void @_ZN1FC1EOS_
110// CHECK-CTOR: call void @_ZN1EC1EOS_
Sebastian Redl22653ba2011-08-30 19:58:05 +0000111// array loop
Douglas Gregor528499b2011-09-01 02:09:07 +0000112// CHECK-CTOR: br i1
113// CHECK-CTOR: call void @_ZN1FC1EOS_
Sebastian Redl22653ba2011-08-30 19:58:05 +0000114
Douglas Gregor528499b2011-09-01 02:09:07 +0000115// CHECK-CTOR: define linkonce_odr void @_ZN1GC2EOS_
116// CHECK-CTOR: call void @_ZN1EC1EOS_