John McCall | 9fc6a77 | 2010-02-19 09:25:03 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 %s -emit-llvm -o - -mconstructor-aliases | FileCheck %s |
Anders Carlsson | 174754c | 2009-09-01 18:33:46 +0000 | [diff] [blame] | 2 | struct A { |
| 3 | int a; |
| 4 | |
| 5 | ~A(); |
| 6 | }; |
| 7 | |
| 8 | // Base with non-trivial destructor |
| 9 | struct B : A { |
| 10 | ~B(); |
| 11 | }; |
| 12 | |
| 13 | B::~B() { } |
| 14 | |
| 15 | // Field with non-trivial destructor |
| 16 | struct C { |
| 17 | A a; |
| 18 | |
| 19 | ~C(); |
| 20 | }; |
| 21 | |
Douglas Gregor | 4513272 | 2009-10-01 20:44:19 +0000 | [diff] [blame] | 22 | C::~C() { } |
| 23 | |
| 24 | // PR5084 |
| 25 | template<typename T> |
| 26 | class A1 { |
| 27 | ~A1(); |
| 28 | }; |
| 29 | |
| 30 | template<> A1<char>::~A1(); |
Anders Carlsson | 9f853df | 2009-11-17 04:44:12 +0000 | [diff] [blame] | 31 | |
| 32 | // PR5529 |
| 33 | namespace PR5529 { |
| 34 | struct A { |
| 35 | ~A(); |
| 36 | }; |
| 37 | |
| 38 | A::~A() { } |
| 39 | struct B : A { |
| 40 | virtual ~B(); |
| 41 | }; |
| 42 | |
| 43 | B::~B() {} |
| 44 | } |
John McCall | 9fc6a77 | 2010-02-19 09:25:03 +0000 | [diff] [blame^] | 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. |
| 49 | namespace 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 | } |