Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / eh-aggregated-inits-unwind.cpp
blob64142f76a2019fdf4ccd6b30075a7383a71f0dfb
1 // Check that destructors of memcpy-able struct members are called properly
2 // during stack unwinding after an exception.
3 //
4 // Check that destructor's argument (address of member to be destroyed) is
5 // obtained by taking offset from struct, not by bitcasting pointers.
6 //
7 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -O0 -fno-elide-constructors -emit-llvm %s -o - | FileCheck %s
9 struct ImplicitCopy {
10 int id;
11 ImplicitCopy() { id = 10; }
12 ~ImplicitCopy() { id = 20; }
15 struct ThrowCopy {
16 int id;
17 ThrowCopy() { id = 15; }
18 ThrowCopy(const ThrowCopy &x) {
19 id = 25;
20 throw 1;
22 ~ThrowCopy() { id = 35; }
25 struct Container {
26 int id;
27 ImplicitCopy o1;
28 ThrowCopy o2;
30 Container() { id = 1000; }
31 ~Container() { id = 2000; }
34 int main() {
35 try {
36 Container c1;
37 // CHECK-LABEL: main
38 // CHECK: %{{.+}} = getelementptr inbounds %struct.Container, ptr %{{.+}}, i32 0, i32 1
39 Container c2(c1);
41 return 2;
42 } catch (...) {
43 return 1;
45 return 0;