destructors.cpp revision 9fc6a7774643a810c8501dae2323e863fefb623e
1// RUN: %clang_cc1 %s -emit-llvm -o - -mconstructor-aliases | FileCheck %s 2struct A { 3 int a; 4 5 ~A(); 6}; 7 8// Base with non-trivial destructor 9struct B : A { 10 ~B(); 11}; 12 13B::~B() { } 14 15// Field with non-trivial destructor 16struct C { 17 A a; 18 19 ~C(); 20}; 21 22C::~C() { } 23 24// PR5084 25template<typename T> 26class A1 { 27 ~A1(); 28}; 29 30template<> A1<char>::~A1(); 31 32// PR5529 33namespace PR5529 { 34 struct A { 35 ~A(); 36 }; 37 38 A::~A() { } 39 struct B : A { 40 virtual ~B(); 41 }; 42 43 B::~B() {} 44} 45 46// FIXME: there's a known problem in the codegen here where, if one 47// destructor throws, the remaining destructors aren't run. Fix it, 48// then make this code check for it. 49namespace test0 { 50 void foo(); 51 struct VBase { ~VBase(); }; 52 struct Base { ~Base(); }; 53 struct Member { ~Member(); }; 54 55 struct A : Base { 56 Member M; 57 ~A(); 58 }; 59 60 // The function-try-block won't suppress -mconstructor-aliases here. 61 A::~A() try { } catch (int i) {} 62 63// CHECK: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev 64 65// CHECK: define void @_ZN5test01AD2Ev 66// CHECK: invoke void @_ZN5test06MemberD1Ev 67// CHECK: unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]] 68// CHECK: invoke void @_ZN5test04BaseD2Ev 69// CHECK: unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]] 70 71 struct B : Base, virtual VBase { 72 Member M; 73 ~B(); 74 }; 75 B::~B() try { } catch (int i) {} 76 // It will suppress the delegation optimization here, though. 77 78// CHECK: define void @_ZN5test01BD1Ev 79// CHECK: invoke void @_ZN5test06MemberD1Ev 80// CHECK: unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]] 81// CHECK: invoke void @_ZN5test04BaseD2Ev 82// CHECK: unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]] 83// CHECK: invoke void @_ZN5test05VBaseD2Ev 84// CHECK: unwind label [[VBASE_UNWIND:%[a-zA-Z0-9.]+]] 85 86// CHECK: define void @_ZN5test01BD2Ev 87// CHECK: invoke void @_ZN5test06MemberD1Ev 88// CHECK: unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]] 89// CHECK: invoke void @_ZN5test04BaseD2Ev 90// CHECK: unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]] 91} 92