1// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -fexceptions -fcxx-exceptions -std=c++11 -o - %s | FileCheck %s
2
3struct non_trivial {
4  non_trivial();
5  ~non_trivial() noexcept(false);
6};
7non_trivial::non_trivial() {}
8non_trivial::~non_trivial() noexcept(false) {}
9
10// We use a virtual base to ensure that the constructor
11// delegation optimization (complete->base) can't be
12// performed.
13struct delegator {
14  non_trivial n;
15  delegator();
16  delegator(int);
17  delegator(char);
18  delegator(bool);
19};
20
21delegator::delegator() {
22  throw 0;
23}
24
25
26delegator::delegator(bool)
27{}
28
29// CHECK-LABEL: define {{.*}} @_ZN9delegatorC2Ec
30// CHECK: {{.*}} @_ZN9delegatorC2Eb
31// CHECK: void @__cxa_throw
32// CHECK: void @__clang_call_terminate
33// CHECK: {{.*}} @_ZN9delegatorD2Ev
34
35// CHECK-LABEL: define {{.*}} @_ZN9delegatorC1Ec
36// CHECK: {{.*}} @_ZN9delegatorC1Eb
37// CHECK: void @__cxa_throw
38// CHECK: void @__clang_call_terminate
39// CHECK: {{.*}} @_ZN9delegatorD1Ev
40delegator::delegator(char)
41  : delegator(true) {
42  throw 0;
43}
44
45// CHECK-LABEL: define {{.*}} @_ZN9delegatorC2Ei
46// CHECK: {{.*}} @_ZN9delegatorC2Ev
47// CHECK-NOT: void @_ZSt9terminatev
48// CHECK: ret
49// CHECK-NOT: void @_ZSt9terminatev
50
51// CHECK-LABEL: define {{.*}} @_ZN9delegatorC1Ei
52// CHECK: {{.*}} @_ZN9delegatorC1Ev
53// CHECK-NOT: void @_ZSt9terminatev
54// CHECK: ret
55// CHECK-NOT: void @_ZSt9terminatev
56delegator::delegator(int)
57  : delegator()
58{}
59
60namespace PR12890 {
61  class X {
62    int x;
63    X() = default;
64    X(int);
65  };
66  X::X(int) : X() {}
67}
68// CHECK: define {{.*}} @_ZN7PR128901XC1Ei(%"class.PR12890::X"* %this, i32)
69// CHECK: call void @llvm.memset.p0i8.{{i32|i64}}(i8* {{.*}}, i8 0, {{i32|i64}} 4, i32 4, i1 false)
70
71namespace PR14588 {
72  void other();
73
74  class Base {
75  public:
76    Base() { squawk(); }
77    virtual ~Base() {}
78
79    virtual void squawk() { other(); }
80  };
81
82
83  class Foo : public virtual Base {
84  public:
85    Foo();
86    Foo(const void * inVoid);
87    virtual ~Foo() {}
88
89    virtual void squawk() { other(); }
90  };
91
92  // CHECK-LABEL: define void @_ZN7PR145883FooC1Ev(%"class.PR14588::Foo"*
93  // CHECK: call void @_ZN7PR145883FooC1EPKv(
94  // CHECK: invoke void @_ZN7PR145885otherEv()
95  // CHECK: call void @_ZN7PR145883FooD1Ev
96  // CHECK: resume
97
98  Foo::Foo() : Foo(__null) { other(); }
99  Foo::Foo(const void *inVoid) {
100    squawk();
101  }
102
103}
104