125 lines · plain
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-OBJ2// RUN: %clang_cc1 -x c++ -emit-llvm -triple x86_64-apple-darwin10.0.0 -o - %s | FileCheck %s -check-prefix=CHECK-CPP3#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 noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_ZN1DaSERS_47// CHECK-OBJ: {{call.*_ZN1AaSERS_}}48// CHECK-OBJ: {{call.*_ZN1BaSERS_}}49// CHECK-OBJ: {{call.*_ZN1CaSERKS_}}50// CHECK-OBJ: {{call void @llvm.memcpy.p0.p0.i64.*i64 24}}51// CHECK-OBJ: {{call.*_ZN1BaSERS_}}52// CHECK-OBJ: br53// CHECK-OBJ: {{call.*_ZN1CaSERKS_}}54// CHECK-OBJ: {{call.*@objc_memmove_collectable}}55// CHECK-OBJ: {{call void @llvm.memcpy.p0.p0.i64.*i64 12}}56// CHECK-OBJ: call void @_ZN11CopyByValueC1ERKS_57// CHECK-OBJ: {{call.*_ZN11CopyByValueaSES_}}58// CHECK-OBJ: ret59#endif60 61namespace PR13329 {62#ifndef __OBJC__63 typedef void* id;64#endif65 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 1689 // CHECK-CPP: @llvm.memcpy{{.*}}i64 1690 b = a;91 }92 93 void testNonPOD() {94 NonPOD a;95 NonPOD b;96 // CHECK-OBJ: @objc_memmove_collectable{{.*}}i64 1097 // CHECK-CPP: @llvm.memcpy{{.*}}i64 1098 b = a;99 }100 101 void testDerivedNonPOD() {102 DerivedNonPOD a;103 NonPOD b;104 DerivedNonPOD c;105 // CHECK-OBJ: @objc_memmove_collectable{{.*}}i64 10106 // CHECK-CPP: @llvm.memcpy{{.*}}i64 10107 (NonPOD&) a = b;108 // CHECK-OBJ: @objc_memmove_collectable{{.*}}i64 11109 // CHECK-CPP: @llvm.memcpy{{.*}}i64 11110 a = c;111 };112 113 void testDerivedPOD() {114 DerivedPOD a;115 POD b;116 DerivedPOD c;117 // CHECK-OBJ: @objc_memmove_collectable{{.*}}i64 16118 // CHECK-CPP: @llvm.memcpy{{.*}}i64 16119 (POD&) a = b;120 // CHECK-OBJ: @objc_memmove_collectable{{.*}}i64 17121 // CHECK-CPP: @llvm.memcpy{{.*}}i64 17122 a = c;123 };124}125