brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 6b32545 Raw
109 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -std=c++11 | FileCheck %s2 3struct A { 4  A();5  A(const A&);6  A(A&);7  ~A();8};9 10struct B {11  B();12  B(B&);13};14 15struct C {16  C() {}17  C(C& other, A a = A());18  int i, j;19};20 21struct POD {22  int array[3][4];23};24 25struct D : A, B, virtual C { 26  D();27  int scalar;28  int scalar_array[2][3];29  B class_member;30  C class_member_array[2][3];31  POD pod_array[2][3];32 33  union {34    int x;35    float f[3];36  };37};38 39void f(D d) {40  D d2(d);41}42 43// CHECK-LABEL: define linkonce_odr void @_ZN1DC1ERS_(ptr {{[^,]*}} %this, ptr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0) unnamed_addr44// CHECK: call void @_ZN1AC1Ev45// CHECK: call void @_ZN1CC2ERS_1A46// CHECK: call void @_ZN1AD1Ev47// CHECK: call void @_ZN1AC2ERS_48// CHECK: call void @_ZN1BC2ERS_49// CHECK: {{call void @llvm.memcpy.p0.p0.i64.*i64 28}}50// CHECK: call void @_ZN1BC1ERS_51// CHECK: br label52// CHECK: call void @_ZN1AC1Ev53// CHECK: call void @_ZN1CC1ERS_1A54// CHECK: call void @_ZN1AD1Ev55// CHECK: {{icmp eq.*, 3}}56// CHECK: br i157// CHECK: {{icmp eq.*, 2}}58// CHECK: br i159// CHECK: {{call void @llvm.memcpy.p0.p0.i64.*i64 300}}60// CHECK: ret void61 62 63template<class T> struct X0 { void f0(T * ) { } };64template <class > struct X1 { X1( X1& , int = 0 ) { } };65struct X2 { X1<int> result; };66void test_X2()67{68  typedef X2 impl;69  typedef X0<impl> pimpl;70  impl* i;71  pimpl pdata;72  pdata.f0( new impl(*i));73}74 75namespace test3 {76  struct A { A(const A&); A&operator=(const A&); };77  struct B { A a; unsigned : 0; };78  void test(const B &x) {79    B y = x;80    y = x;81  }82}83 84namespace test4 {85  // When determining whether to implement an array copy as a memcpy, look at86  // whether the *selected* constructor is trivial.87  struct S {88    int arr[5][5];89    S(S &);90    S(const S &) = default;91  };92  // CHECK: @_ZN5test42f193  void f1(S a) {94    // CHECK-NOT: memcpy95    // CHECK: call void @_ZN5test41SC1ERS0_96    // CHECK-NOT: memcpy97    S b(a);98    // CHECK: }99  }100  // CHECK: @_ZN5test42f2101  void f2(const S a) {102    // CHECK-NOT: call void @_ZN5test41SC1ERS0_103    // CHECK: memcpy104    // CHECK-NOT: call void @_ZN5test41SC1ERS0_105    S b(a);106    // CHECK: }107  }108}109