1 // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
4 struct Spacer
{ int x
; };
5 struct A
{ double array
[2]; };
6 struct B
: Spacer
, A
{ };
10 // CHECK-LABEL: define{{.*}} nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z4getAv()
11 // CHECK: call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z4getBv()
12 // CHECK-NEXT: getelementptr inbounds i8, ptr
13 // CHECK-NEXT: ret ptr
14 A
&&getA() { return static_cast<A
&&>(getB()); }
20 // CHECK-LABEL: define{{.*}} nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z2f0v()
21 // CHECK: call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z12getIntLValuev()
22 // CHECK-NEXT: ret ptr
23 int &&f0() { return static_cast<int&&>(getIntLValue()); }
25 // CHECK-LABEL: define{{.*}} nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z2f1v()
26 // CHECK: call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z12getIntXValuev()
27 // CHECK-NEXT: ret ptr
28 int &&f1() { return static_cast<int&&>(getIntXValue()); }
30 // CHECK-LABEL: define{{.*}} nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_Z2f2v
31 // CHECK: call noundef i32 @_Z13getIntPRValuev()
32 // CHECK-NEXT: store i32 {{.*}}, ptr
33 // CHECK-NEXT: ret ptr
34 int &&f2() { return static_cast<int&&>(getIntPRValue()); }
43 C
& operator=(const C
&) = delete;
45 C(int state
) : state_(new int(state
)) { }
60 // CHECK-LABEL: define{{.*}} void @_Z15elide_copy_initv
61 void elide_copy_init() {
63 // CHECK: call void @_Z4testv
65 // CHECK-NEXT: call void @_ZN1CD1Ev
66 // CHECK-NEXT: ret void
69 // CHECK-LABEL: define{{.*}} void @_Z16test_move_returnv
70 C
test_move_return() {
71 // CHECK: call void @_ZN1CC1Ei
73 // CHECK: call void @_ZN1CC1Ei
76 // CHECK: call void @_ZN1CC1EOS_
78 // CHECK: call void @_ZN1CC1EOS_
80 // CHECK: call void @_ZN1CD1Ev
81 // CHECK: call void @_ZN1CD1Ev
85 // PR10800: don't crash
95 // CHECK-LABEL: define{{.*}} void @_ZN5test11BC2Ei(
96 // CHECK: [[T0:%.*]] = call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_ZN5test14moveERi(
97 // CHECK-NEXT: [[T1:%.*]] = load i32, ptr [[T0]]
98 // CHECK-NEXT: call void @_ZN5test11AC1Ei({{.*}}, i32 noundef [[T1]])
99 // CHECK-NEXT: ret void
100 B::B(int i
) : a(move(i
)) {}
104 struct MoveConvertible
{
105 operator int&& () const;
107 void moveConstruct() {
108 (void)(int)MoveConvertible();