blob: a4a688f737d76fdebb757326d254b79e64fb068c [file] [log] [blame]
Eli Friedmancb48f8a2009-12-24 23:33:34 +00001// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
2
3struct A { int x; A(int); ~A(); };
4A f() { return A(0); }
5// CHECK: define void @_Z1fv
Eli Friedman41f1fd42011-06-13 22:51:21 +00006// CHECK: call {{.*}} @_ZN1AC1Ei
Eli Friedmancb48f8a2009-12-24 23:33:34 +00007// CHECK-NEXT: ret void
Douglas Gregorb8f7de92010-08-22 18:27:02 +00008
9// Verify that we do not elide copies when constructing a base class.
10namespace 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 Lattner9cbe4f02011-07-09 17:41:47 +000024 // CHECK: define {{.*}} @_ZN13no_elide_base7DerivedC1ERKNS_5OtherE(%"struct.no_elide_base::Derived"* %this, %"struct.no_elide_base::Other"* %O) unnamed_addr
Douglas Gregorb8f7de92010-08-22 18:27:02 +000025 Derived::Derived(const Other &O)
Eli Friedman41f1fd42011-06-13 22:51:21 +000026 // CHECK: call {{.*}} @_ZNK13no_elide_base5OthercvNS_4BaseEEv
27 // CHECK: call {{.*}} @_ZN13no_elide_base4BaseC2ERKS0_
28 // CHECK: call {{.*}} @_ZN13no_elide_base4BaseD1Ev
Douglas Gregorb8f7de92010-08-22 18:27:02 +000029 : Base(O)
30 {
Eli Friedman41f1fd42011-06-13 22:51:21 +000031 // CHECK: ret
Douglas Gregorb8f7de92010-08-22 18:27:02 +000032 }
33}
Anders Carlssonf8b30152010-11-28 16:40:49 +000034
35// PR8683.
36
37namespace PR8683 {
38
39struct A {
40 A();
41 A(const A&);
42 A& operator=(const A&);
43};
44
45struct B {
46 A a;
47};
48
49void f() {
50 // Verify that we don't mark the copy constructor in this expression as elidable.
Eli Friedman12e9f8e2011-06-14 21:20:53 +000051 // CHECK: call {{.*}} @_ZN6PR86831AC1ERKS0_
Anders Carlssonf8b30152010-11-28 16:40:49 +000052 A a = (B().a);
53}
54
55}