1// RUN: %clang_cc1 -fobjc-gc -emit-llvm -triple x86_64-apple-darwin10.0.0 -fobjc-runtime=macosx-fragile-10.5 -o - %s | FileCheck %s -check-prefix=CHECK-OBJ 2// RUN: %clang_cc1 -x c++ -emit-llvm -triple x86_64-apple-darwin10.0.0 -o - %s | FileCheck %s -check-prefix=CHECK-CPP 3#ifdef __OBJC__ 4struct A { 5 A &operator=(const A&); 6 A &operator=(A&); 7}; 8 9struct B { 10 B &operator=(B&); 11}; 12 13struct C { 14 virtual C& operator=(const C&); 15}; 16 17struct POD { 18 id myobjc; 19 int array[3][4]; 20}; 21 22struct CopyByValue { 23 CopyByValue(const CopyByValue&); 24 CopyByValue &operator=(CopyByValue); 25}; 26 27struct D : A, B, virtual C { 28 int scalar; 29 int scalar_array[2][3]; 30 B class_member; 31 C class_member_array[2][3]; 32 POD pod_array[2][3]; 33 34 union { 35 int x; 36 float f[3]; 37 }; 38 39 CopyByValue by_value; 40}; 41 42void test_D(D d1, D d2) { 43 d1 = d2; 44} 45 46// CHECK-OBJ-LABEL: define linkonce_odr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %struct.D* @_ZN1DaSERS_ 47// CHECK-OBJ: {{call.*_ZN1AaSERS_}} 48// CHECK-OBJ: {{call.*_ZN1BaSERS_}} 49// CHECK-OBJ: {{call.*_ZN1CaSERKS_}} 50// CHECK-OBJ: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 24}} 51// CHECK-OBJ: {{call.*_ZN1BaSERS_}} 52// CHECK-OBJ: br 53// CHECK-OBJ: {{call.*_ZN1CaSERKS_}} 54// CHECK-OBJ: {{call.*@objc_memmove_collectable}} 55// CHECK-OBJ: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 12}} 56// CHECK-OBJ: call void @_ZN11CopyByValueC1ERKS_ 57// CHECK-OBJ: {{call.*_ZN11CopyByValueaSES_}} 58// CHECK-OBJ: ret 59#endif 60 61namespace PR13329 { 62#ifndef __OBJC__ 63 typedef void* id; 64#endif 65 struct POD { 66 id i; 67 short s; 68 }; 69 70 struct NonPOD { 71 id i; 72 short s; 73 74 NonPOD(); 75 }; 76 77 struct DerivedNonPOD: NonPOD { 78 char c; 79 }; 80 81 struct DerivedPOD: POD { 82 char c; 83 }; 84 85 void testPOD() { 86 POD a; 87 POD b; 88 // CHECK-OBJ: @objc_memmove_collectable{{.*}}i64 16 89 // CHECK-CPP: @llvm.memcpy{{.*}}i64 16 90 b = a; 91 } 92 93 void testNonPOD() { 94 NonPOD a; 95 NonPOD b; 96 // CHECK-OBJ: @objc_memmove_collectable{{.*}}i64 10 97 // CHECK-CPP: @llvm.memcpy{{.*}}i64 10 98 b = a; 99 } 100 101 void testDerivedNonPOD() { 102 DerivedNonPOD a; 103 NonPOD b; 104 DerivedNonPOD c; 105 // CHECK-OBJ: @objc_memmove_collectable{{.*}}i64 10 106 // CHECK-CPP: @llvm.memcpy{{.*}}i64 10 107 (NonPOD&) a = b; 108 // CHECK-OBJ: @objc_memmove_collectable{{.*}}i64 11 109 // CHECK-CPP: @llvm.memcpy{{.*}}i64 11 110 a = c; 111 }; 112 113 void testDerivedPOD() { 114 DerivedPOD a; 115 POD b; 116 DerivedPOD c; 117 // CHECK-OBJ: @objc_memmove_collectable{{.*}}i64 16 118 // CHECK-CPP: @llvm.memcpy{{.*}}i64 16 119 (POD&) a = b; 120 // CHECK-OBJ: @objc_memmove_collectable{{.*}}i64 17 121 // CHECK-CPP: @llvm.memcpy{{.*}}i64 17 122 a = c; 123 }; 124} 125