Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s
      2 
      3 struct Member {
      4   ~Member();
      5 };
      6 
      7 struct A {
      8   virtual ~A();
      9 };
     10 
     11 struct B : A {
     12   Member m;
     13   virtual ~B();
     14 };
     15 
     16 // Complete dtor: just an alias because there are no virtual bases.
     17 // CHECK: @_ZN1BD1Ev = alias {{.*}} @_ZN1BD2Ev
     18 
     19 // (aliases from C)
     20 // CHECK: @_ZN1CD2Ev = alias {{.*}}, bitcast {{.*}} @_ZN1BD2Ev
     21 // CHECK: @_ZN1CD1Ev = alias {{.*}} @_ZN1CD2Ev
     22 
     23 // Base dtor: actually calls A's base dtor.
     24 // CHECK-LABEL: define void @_ZN1BD2Ev(%struct.B* %this) unnamed_addr
     25 // CHECK: call void @_ZN6MemberD1Ev
     26 // CHECK: call void @_ZN1AD2Ev
     27 
     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 
     33 B::~B() { }
     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.
     44 // CHECK-LABEL: define void @_ZN1CD0Ev(%struct.C* %this) unnamed_addr
     45 // CHECK: call void @_ZN1CD1Ev
     46 // CHECK: call void @_ZdlPv
     47 
     48 // Base dtor: just an alias to B's base dtor.
     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 }
     60