Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / cxx0x-delegating-ctors.cpp
blobbf67870e71fab3956aec064509951c593a6ae145
1 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -fexceptions -fcxx-exceptions -std=c++11 -o - %s | FileCheck %s
3 struct non_trivial {
4 non_trivial();
5 ~non_trivial() noexcept(false);
6 };
7 non_trivial::non_trivial() {}
8 non_trivial::~non_trivial() noexcept(false) {}
10 // We use a virtual base to ensure that the constructor
11 // delegation optimization (complete->base) can't be
12 // performed.
13 struct delegator {
14 non_trivial n;
15 delegator();
16 delegator(int);
17 delegator(char);
18 delegator(bool);
21 delegator::delegator() {
22 throw 0;
26 delegator::delegator(bool)
29 // CHECK-LABEL: define {{.*}} @_ZN9delegatorC2Ec
30 // CHECK: {{.*}} @_ZN9delegatorC2Eb
31 // CHECK: void @__cxa_throw
32 // CHECK: void @__clang_call_terminate
33 // CHECK: {{.*}} @_ZN9delegatorD2Ev
35 // CHECK-LABEL: define {{.*}} @_ZN9delegatorC1Ec
36 // CHECK: {{.*}} @_ZN9delegatorC1Eb
37 // CHECK: void @__cxa_throw
38 // CHECK: void @__clang_call_terminate
39 // CHECK: {{.*}} @_ZN9delegatorD1Ev
40 delegator::delegator(char)
41 : delegator(true) {
42 throw 0;
45 // CHECK-LABEL: define {{.*}} @_ZN9delegatorC2Ei
46 // CHECK: {{.*}} @_ZN9delegatorC2Ev
47 // CHECK-NOT: void @_ZSt9terminatev
48 // CHECK: ret
49 // CHECK-NOT: void @_ZSt9terminatev
51 // CHECK-LABEL: define {{.*}} @_ZN9delegatorC1Ei
52 // CHECK: {{.*}} @_ZN9delegatorC1Ev
53 // CHECK-NOT: void @_ZSt9terminatev
54 // CHECK: ret
55 // CHECK-NOT: void @_ZSt9terminatev
56 delegator::delegator(int)
57 : delegator()
60 namespace PR12890 {
61 class X {
62 int x;
63 X() = default;
64 X(int);
66 X::X(int) : X() {}
68 // CHECK: define {{.*}} @_ZN7PR128901XC1Ei(ptr {{[^,]*}} %this, i32 noundef %0)
69 // CHECK: call void @llvm.memset.p0.{{i32|i64}}(ptr align 4 {{.*}}, i8 0, {{i32|i64}} 4, i1 false)
71 namespace PR14588 {
72 void other();
74 class Base {
75 public:
76 Base() { squawk(); }
77 virtual ~Base() {}
79 virtual void squawk() { other(); }
83 class Foo : public virtual Base {
84 public:
85 Foo();
86 Foo(const void * inVoid);
87 virtual ~Foo() {}
89 virtual void squawk() { other(); }
92 // CHECK-LABEL: define{{.*}} void @_ZN7PR145883FooC1Ev(ptr
93 // CHECK: call void @_ZN7PR145883FooC1EPKv(
94 // CHECK: invoke void @_ZN7PR145885otherEv()
95 // CHECK: call void @_ZN7PR145883FooD1Ev
96 // CHECK: resume
98 Foo::Foo() : Foo(__null) { other(); }
99 Foo::Foo(const void *inVoid) {
100 squawk();