16cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// RUN: %clang_cc1 -triple x86_64-apple-darwin12 -emit-llvm -o - -std=c++11 %s -DPOD | FileCheck %s -check-prefix=CHECK-POD 26cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// RUN: %clang_cc1 -triple x86_64-apple-darwin12 -emit-llvm -o - -std=c++11 %s | FileCheck %s -check-prefix=CHECK-NONPOD 36cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 46cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// Declare the reserved placement operators. 56cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramertypedef __typeof__(sizeof(0)) size_t; 66cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramervoid *operator new(size_t, void*) throw(); 76cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramervoid operator delete(void*, void*) throw(); 86cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramervoid *operator new[](size_t, void*) throw(); 96cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramervoid operator delete[](void*, void*) throw(); 106cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramertemplate<typename T> T &&move(T&); 116cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 126cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramerstruct foo { 136cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer#ifndef POD 146cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer foo() {} // non-POD 156cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer#endif 166cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer void *a, *b; 176cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer bool c; 186cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer}; 196cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 206cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// It is not legal to copy the tail padding in all cases, but if it is it can 216cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// yield better codegen. 226cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 236cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramerfoo *test1(void *f, const foo &x) { 246cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer return new (f) foo(x); 256cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: test1 266cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 276cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 286cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: test1 296cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 306cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer} 316cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 326cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramerfoo *test2(const foo &x) { 336cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer return new foo(x); 346cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: test2 356cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 366cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 376cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: test2 386cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 396cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer} 406cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 416cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramerfoo test3(const foo &x) { 426cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer foo f = x; 436cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer return f; 446cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: test3 456cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 466cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 476cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: test3 486cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 496cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer} 506cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 516cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramerfoo *test4(foo &&x) { 526cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer return new foo(x); 536cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: test4 546cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 556cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 566cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: test4 576cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 586cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer} 596cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 606cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramervoid test5(foo &f, const foo &x) { 616cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer f = x; 626cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: test5 636cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 646cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 656cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: test5 666cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 17, i32 8 676cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer} 686cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 696cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramerextern foo globtest; 706cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 716cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramervoid test6(foo &&x) { 726cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer globtest = move(x); 736cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: test6 746cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 756cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 766cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: test6 776cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 17, i32 8 786cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer} 796cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 806cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramervoid byval(foo f); 816cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 826cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramervoid test7(const foo &x) { 836cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer byval(x); 846cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: test7 856cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-POD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 866cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer 876cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: test7 886cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer// CHECK-NONPOD: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 24, i32 8 896cacae8bf9597b8124cd40aedc189c04484e1990Benjamin Kramer} 90