David Blaikie | 1b76fbc | 2012-09-10 23:06:08 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s |
Eli Friedman | cb48f8a | 2009-12-24 23:33:34 +0000 | [diff] [blame] | 2 | |
| 3 | struct A { int x; A(int); ~A(); }; |
| 4 | A f() { return A(0); } |
| 5 | // CHECK: define void @_Z1fv |
Eli Friedman | 41f1fd4 | 2011-06-13 22:51:21 +0000 | [diff] [blame] | 6 | // CHECK: call {{.*}} @_ZN1AC1Ei |
Eli Friedman | cb48f8a | 2009-12-24 23:33:34 +0000 | [diff] [blame] | 7 | // CHECK-NEXT: ret void |
Douglas Gregor | b8f7de9 | 2010-08-22 18:27:02 +0000 | [diff] [blame] | 8 | |
| 9 | // Verify that we do not elide copies when constructing a base class. |
| 10 | namespace no_elide_base { |
| 11 | struct Base { |
| 12 | Base(const Base&); |
| 13 | ~Base(); |
| 14 | }; |
| 15 | |
| 16 | struct Other { |
| 17 | operator Base() const; |
| 18 | }; |
| 19 | |
| 20 | struct Derived : public virtual Base { |
| 21 | Derived(const Other &O); |
| 22 | }; |
| 23 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 24 | // CHECK: define {{.*}} @_ZN13no_elide_base7DerivedC1ERKNS_5OtherE(%"struct.no_elide_base::Derived"* %this, %"struct.no_elide_base::Other"* %O) unnamed_addr |
Douglas Gregor | b8f7de9 | 2010-08-22 18:27:02 +0000 | [diff] [blame] | 25 | Derived::Derived(const Other &O) |
Eli Friedman | 41f1fd4 | 2011-06-13 22:51:21 +0000 | [diff] [blame] | 26 | // CHECK: call {{.*}} @_ZNK13no_elide_base5OthercvNS_4BaseEEv |
| 27 | // CHECK: call {{.*}} @_ZN13no_elide_base4BaseC2ERKS0_ |
| 28 | // CHECK: call {{.*}} @_ZN13no_elide_base4BaseD1Ev |
Douglas Gregor | b8f7de9 | 2010-08-22 18:27:02 +0000 | [diff] [blame] | 29 | : Base(O) |
| 30 | { |
Eli Friedman | 41f1fd4 | 2011-06-13 22:51:21 +0000 | [diff] [blame] | 31 | // CHECK: ret |
Douglas Gregor | b8f7de9 | 2010-08-22 18:27:02 +0000 | [diff] [blame] | 32 | } |
| 33 | } |
Anders Carlsson | f8b3015 | 2010-11-28 16:40:49 +0000 | [diff] [blame] | 34 | |
| 35 | // PR8683. |
| 36 | |
| 37 | namespace PR8683 { |
| 38 | |
| 39 | struct A { |
| 40 | A(); |
| 41 | A(const A&); |
| 42 | A& operator=(const A&); |
| 43 | }; |
| 44 | |
| 45 | struct B { |
| 46 | A a; |
| 47 | }; |
| 48 | |
| 49 | void f() { |
| 50 | // Verify that we don't mark the copy constructor in this expression as elidable. |
Eli Friedman | 12e9f8e | 2011-06-14 21:20:53 +0000 | [diff] [blame] | 51 | // CHECK: call {{.*}} @_ZN6PR86831AC1ERKS0_ |
Anders Carlsson | f8b3015 | 2010-11-28 16:40:49 +0000 | [diff] [blame] | 52 | A a = (B().a); |
| 53 | } |
| 54 | |
| 55 | } |
Douglas Gregor | f52757d | 2012-03-10 06:53:13 +0000 | [diff] [blame] | 56 | |
| 57 | namespace PR12139 { |
| 58 | struct A { |
| 59 | A() : value(1) { } |
| 60 | A(A const &, int value = 2) : value(value) { } |
| 61 | int value; |
| 62 | |
| 63 | static A makeA() { A a; a.value = 2; return a; } |
| 64 | }; |
| 65 | |
| 66 | // CHECK: define i32 @_ZN7PR121394testEv |
| 67 | int test() { |
| 68 | // CHECK: call void @_ZN7PR121391A5makeAEv |
David Blaikie | 1b76fbc | 2012-09-10 23:06:08 +0000 | [diff] [blame] | 69 | // CHECK-NEXT: call %"struct.PR12139::A"* @_ZN7PR121391AC1ERKS0_i |
Douglas Gregor | f52757d | 2012-03-10 06:53:13 +0000 | [diff] [blame] | 70 | A a(A::makeA(), 3); |
| 71 | // CHECK-NEXT: getelementptr inbounds |
| 72 | // CHECK-NEXT: load |
| 73 | // CHECK-NEXT: ret i32 |
| 74 | return a.value; |
| 75 | } |
| 76 | } |
| 77 | |