| Rafael Espindola | dc8e938 | 2013-11-13 23:20:45 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s |
| Anders Carlsson | fd12649 | 2009-12-04 19:33:17 +0000 | [diff] [blame] | 2 | |
| John McCall | c0bf462 | 2010-02-23 00:48:20 +0000 | [diff] [blame] | 3 | struct Member { |
| 4 | ~Member(); |
| 5 | }; |
| 6 | |
| Anders Carlsson | fd12649 | 2009-12-04 19:33:17 +0000 | [diff] [blame] | 7 | struct A { |
| 8 | virtual ~A(); |
| 9 | }; |
| 10 | |
| 11 | struct B : A { |
| John McCall | c0bf462 | 2010-02-23 00:48:20 +0000 | [diff] [blame] | 12 | Member m; |
| Anders Carlsson | fd12649 | 2009-12-04 19:33:17 +0000 | [diff] [blame] | 13 | virtual ~B(); |
| 14 | }; |
| 15 | |
| John McCall | d46f985 | 2010-02-19 01:32:20 +0000 | [diff] [blame] | 16 | // Complete dtor: just an alias because there are no virtual bases. |
| 17 | // CHECK: @_ZN1BD1Ev = alias {{.*}} @_ZN1BD2Ev |
| Anders Carlsson | c997d42 | 2010-01-02 01:01:18 +0000 | [diff] [blame] | 18 | |
| John McCall | c0bf462 | 2010-02-23 00:48:20 +0000 | [diff] [blame] | 19 | // (aliases from C) |
| Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 20 | // CHECK: @_ZN1CD1Ev = alias {{.*}} @_ZN1BD2Ev |
| 21 | // CHECK: @_ZN1CD2Ev = alias {{.*}} @_ZN1BD2Ev |
| John McCall | c0bf462 | 2010-02-23 00:48:20 +0000 | [diff] [blame] | 22 | |
| John McCall | 3b47733 | 2010-02-18 19:59:28 +0000 | [diff] [blame] | 23 | // Base dtor: actually calls A's base dtor. |
| Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 24 | // CHECK-LABEL: define void @_ZN1BD2Ev(%struct.B* %this) unnamed_addr |
| John McCall | c0bf462 | 2010-02-23 00:48:20 +0000 | [diff] [blame] | 25 | // CHECK: call void @_ZN6MemberD1Ev |
| Anders Carlsson | fd12649 | 2009-12-04 19:33:17 +0000 | [diff] [blame] | 26 | // CHECK: call void @_ZN1AD2Ev |
| 27 | |
| Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 28 | // Deleting dtor: defers to the complete dtor. |
| 29 | // CHECK-LABEL: define void @_ZN1BD0Ev(%struct.B* %this) unnamed_addr |
| 30 | // CHECK: call void @_ZN1BD1Ev |
| 31 | // CHECK: call void @_ZdlPv |
| 32 | |
| Anders Carlsson | fd12649 | 2009-12-04 19:33:17 +0000 | [diff] [blame] | 33 | B::~B() { } |
| John McCall | c0bf462 | 2010-02-23 00:48:20 +0000 | [diff] [blame] | 34 | |
| 35 | struct C : B { |
| 36 | ~C(); |
| 37 | }; |
| 38 | |
| 39 | C::~C() { } |
| 40 | |
| 41 | // Complete dtor: just an alias (checked above). |
| 42 | |
| 43 | // Deleting dtor: defers to the complete dtor. |
| Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 44 | // CHECK-LABEL: define void @_ZN1CD0Ev(%struct.C* %this) unnamed_addr |
| John McCall | c0bf462 | 2010-02-23 00:48:20 +0000 | [diff] [blame] | 45 | // CHECK: call void @_ZN1CD1Ev |
| 46 | // CHECK: call void @_ZdlPv |
| 47 | |
| 48 | // Base dtor: just an alias to B's base dtor. |
| Richard Smith | 6314db9 | 2012-05-15 06:15:11 +0000 | [diff] [blame] | 49 | |
| 50 | namespace PR12798 { |
| 51 | // A qualified call to a base class destructor should not undergo virtual |
| 52 | // dispatch. Template instantiation used to lose the qualifier. |
| 53 | struct A { virtual ~A(); }; |
| 54 | template<typename T> void f(T *p) { p->A::~A(); } |
| 55 | |
| 56 | // CHECK: define {{.*}} @_ZN7PR127981fINS_1AEEEvPT_( |
| 57 | // CHECK: call void @_ZN7PR127981AD1Ev( |
| 58 | template void f(A*); |
| 59 | } |