implicit-move-def.cpp revision b2b5658a8e4ad566303ec98caceaa3485e7635f7
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 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 59// PR10822 60struct I { 61 unsigned var[1]; 62}; 63 64// CHECK: define void @_Z1hv() nounwind { 65void h() { 66 I i; 67 // CHECK: call void @llvm.memcpy. 68 i = I(); 69 // 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 83} 84 85// move assignment ops 86 87// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1DaSEOS_ 88// CHECK-ASSIGN: call {{.*}} @_ZN1CaSEOS_ 89// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_ 90// CHECK-ASSIGN: call {{.*}} @_ZN1BaSEOS_ 91// array loop 92// CHECK-ASSIGN: br i1 93// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_ 94 95// 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 101 102// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1CaSEOS_ 103// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_ 104 105// move ctors 106 107// 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_ 111// array loop 112// CHECK-CTOR: br i1 113// CHECK-CTOR: call void @_ZN1FC1EOS_ 114 115// CHECK-CTOR: define linkonce_odr void @_ZN1GC2EOS_ 116// CHECK-CTOR: call void @_ZN1EC1EOS_ 117