Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / cxx1y-init-captures-eh.cpp
blobb0b938191a0237c6b16917cf5dec6f4134929f83
1 // RUN: %clang_cc1 -std=c++1y -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s
3 struct S {
4 S();
5 ~S();
6 };
8 struct T {
9 T() noexcept;
10 ~T();
11 int n;
14 // CHECK-LABEL: define{{.*}} void @_Z1fv(
15 void f() {
16 // CHECK: call void @_ZN1SC1Ev(
17 // CHECK: invoke void @__cxa_throw
19 // Ensure we call the lambda destructor here, and do not call the destructor
20 // for the capture.
21 // CHECK: landingpad
22 // CHECK-NOT: _ZN1SD
23 // CHECK: call void @"_ZZ1fvEN3$_0D1Ev"(
24 // CHECK-NOT: _ZN1SD
25 // CHECK: resume
26 [s = S()] {}, throw 0;
28 // CHECK: }
31 // CHECK-LABEL: define{{.*}} void @_Z1gv(
32 void g() {
33 // CHECK: call void @_ZN1SC1Ev(
34 // CHECK: invoke void @__cxa_throw
36 // Ensure we call the lambda destructor here, and do not call the destructor
37 // for the capture.
38 // CHECK: landingpad
39 // CHECK-NOT: @"_ZZ1gvEN3$_0D1Ev"(
40 // CHECK: call void @_ZN1SD1Ev(
41 // CHECK-NOT: @"_ZZ1gvEN3$_0D1Ev"(
42 // CHECK: resume
43 [s = S(), t = (throw 0, 1)] {};
45 // CHECK: }
48 void x() noexcept;
49 void y() noexcept;
51 // CHECK-LABEL: define{{.*}} void @_Z1hbb(
52 void h(bool b1, bool b2) {
53 // CHECK: {{.*}} = alloca i1,
54 // CHECK: %[[S_ISACTIVE:.*]] = alloca i1,
55 // CHECK: {{.*}} = alloca i1,
57 // lambda init: s and t, branch on b1
58 // CHECK: call void @_ZN1SC1Ev(
59 // CHECK: store i1 true, ptr %[[S_ISACTIVE]], align 1
60 // CHECK: call void @_ZN1TC1Ev(
61 // CHECK: br i1
63 // throw 1
64 // CHECK: invoke void @__cxa_throw
66 // completion of lambda init, branch on b2
67 // CHECK: store i32 42,
68 // CHECK: store i1 false, ptr %[[S_ISACTIVE]], align 1
69 // CHECK: br i1
71 // throw 2
72 // CHECK: invoke void @__cxa_throw
74 // end of full-expression
75 // CHECK: call void @_Z1xv(
76 // CHECK: call void @"_ZZ1hbbEN3$_0D1Ev"(
77 // CHECK: call void @_ZN1TD1Ev(
78 // CHECK: call void @_Z1yv(
79 // CHECK: ret void
81 // cleanups for throw 1
82 // CHECK: landingpad
83 // CHECK-NOT: @"_ZZ1hbbEN3$_0D1Ev"(
84 // CHECK: br
86 // cleanups for throw 2
87 // CHECK: landingpad
88 // CHECK: call void @"_ZZ1hbbEN3$_0D1Ev"(
89 // CHECK: br
91 // common cleanup code
92 // CHECK: call void @_ZN1TD1Ev(
93 // CHECK: load i1, ptr %[[S_ISACTIVE]],
94 // CHECK: br i1
96 // CHECK: call void @_ZN1SD1Ev(
97 // CHECK: br
99 // CHECK: resume
100 [s = S(), t = T().n, u = (b1 ? throw 1 : 42)] {}, (b2 ? throw 2 : 0), x();
101 y();
103 // CHECK: }