1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuc struct A { int x; A(int); ~A(); }; f()4f4a2713aSLionel SambucA f() { return A(0); } 5f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1fv 6f4a2713aSLionel Sambuc // CHECK: call {{.*}} @_ZN1AC1Ei 7f4a2713aSLionel Sambuc // CHECK-NEXT: ret void 8f4a2713aSLionel Sambuc 9f4a2713aSLionel Sambuc // Verify that we do not elide copies when constructing a base class. 10f4a2713aSLionel Sambuc namespace no_elide_base { 11f4a2713aSLionel Sambuc struct Base { 12f4a2713aSLionel Sambuc Base(const Base&); 13f4a2713aSLionel Sambuc ~Base(); 14f4a2713aSLionel Sambuc }; 15f4a2713aSLionel Sambuc 16f4a2713aSLionel Sambuc struct Other { 17f4a2713aSLionel Sambuc operator Base() const; 18f4a2713aSLionel Sambuc }; 19f4a2713aSLionel Sambuc 20f4a2713aSLionel Sambuc struct Derived : public virtual Base { 21f4a2713aSLionel Sambuc Derived(const Other &O); 22f4a2713aSLionel Sambuc }; 23f4a2713aSLionel Sambuc 24*0a6a1f1dSLionel Sambuc // CHECK: define {{.*}} @_ZN13no_elide_base7DerivedC1ERKNS_5OtherE(%"struct.no_elide_base::Derived"* returned %this, %"struct.no_elide_base::Other"* dereferenceable({{[0-9]+}}) %O) unnamed_addr Derived(const Other & O)25f4a2713aSLionel Sambuc Derived::Derived(const Other &O) 26f4a2713aSLionel Sambuc // CHECK: call {{.*}} @_ZNK13no_elide_base5OthercvNS_4BaseEEv 27f4a2713aSLionel Sambuc // CHECK: call {{.*}} @_ZN13no_elide_base4BaseC2ERKS0_ 28f4a2713aSLionel Sambuc // CHECK: call {{.*}} @_ZN13no_elide_base4BaseD1Ev 29f4a2713aSLionel Sambuc : Base(O) 30f4a2713aSLionel Sambuc { 31f4a2713aSLionel Sambuc // CHECK: ret 32f4a2713aSLionel Sambuc } 33f4a2713aSLionel Sambuc } 34f4a2713aSLionel Sambuc 35f4a2713aSLionel Sambuc // PR8683. 36f4a2713aSLionel Sambuc 37f4a2713aSLionel Sambuc namespace PR8683 { 38f4a2713aSLionel Sambuc 39f4a2713aSLionel Sambuc struct A { 40f4a2713aSLionel Sambuc A(); 41f4a2713aSLionel Sambuc A(const A&); 42f4a2713aSLionel Sambuc A& operator=(const A&); 43f4a2713aSLionel Sambuc }; 44f4a2713aSLionel Sambuc 45f4a2713aSLionel Sambuc struct B { 46f4a2713aSLionel Sambuc A a; 47f4a2713aSLionel Sambuc }; 48f4a2713aSLionel Sambuc f()49f4a2713aSLionel Sambucvoid f() { 50f4a2713aSLionel Sambuc // Verify that we don't mark the copy constructor in this expression as elidable. 51f4a2713aSLionel Sambuc // CHECK: call {{.*}} @_ZN6PR86831AC1ERKS0_ 52f4a2713aSLionel Sambuc A a = (B().a); 53f4a2713aSLionel Sambuc } 54f4a2713aSLionel Sambuc 55f4a2713aSLionel Sambuc } 56f4a2713aSLionel Sambuc 57f4a2713aSLionel Sambuc namespace PR12139 { 58f4a2713aSLionel Sambuc struct A { APR12139::A59f4a2713aSLionel Sambuc A() : value(1) { } APR12139::A60f4a2713aSLionel Sambuc A(A const &, int value = 2) : value(value) { } 61f4a2713aSLionel Sambuc int value; 62f4a2713aSLionel Sambuc makeAPR12139::A63f4a2713aSLionel Sambuc static A makeA() { A a; a.value = 2; return a; } 64f4a2713aSLionel Sambuc }; 65f4a2713aSLionel Sambuc 66f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_ZN7PR121394testEv test()67f4a2713aSLionel Sambuc int test() { 68f4a2713aSLionel Sambuc // CHECK: call void @_ZN7PR121391A5makeAEv 69f4a2713aSLionel Sambuc // CHECK-NEXT: call %"struct.PR12139::A"* @_ZN7PR121391AC1ERKS0_i 70f4a2713aSLionel Sambuc A a(A::makeA(), 3); 71f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds 72f4a2713aSLionel Sambuc // CHECK-NEXT: load 73f4a2713aSLionel Sambuc // CHECK-NEXT: ret i32 74f4a2713aSLionel Sambuc return a.value; 75f4a2713aSLionel Sambuc } 76f4a2713aSLionel Sambuc } 77