optimization. Make sure to require a vtable when trying to get the address
of a VTT, otherwise we would never end up emitting the VTT.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131400
91177308-0d34-0410-b5e6-
96231b3b80d8
/// CanSkipVTablePointerInitialization - Check whether we need to initialize
/// any vtable pointers before calling this destructor.
static bool CanSkipVTablePointerInitialization(ASTContext &Context,
- const CXXDestructorDecl *Dtor) {
+ const CXXDestructorDecl *Dtor) {
if (!Dtor->hasTrivialBody())
return false;
Out.flush();
llvm::StringRef Name = OutName.str();
+ ComputeVTableRelatedInformation(RD, /*VTableRequired=*/true);
+
VTTBuilder Builder(CGM, RD, /*GenerateDefinition=*/false);
const llvm::Type *Int8PtrTy =
Out.flush();
llvm::StringRef Name = OutName.str();
- ComputeVTableRelatedInformation(RD, true);
+ ComputeVTableRelatedInformation(RD, /*VTableRequired=*/true);
const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
llvm::ArrayType *ArrayType =
// CHECK: @_ZTCSd0_Si = linkonce_odr unnamed_addr constant
// CHECK: @_ZTCSd16_So = linkonce_odr unnamed_addr constant
// CHECK: @_ZTTSo = linkonce_odr unnamed_addr constant
-// CHECK: @_ZTTSi = linkonce_odr unnamed_addr constant
// CHECK: @_ZTVSo = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTTSi = linkonce_odr unnamed_addr constant
// CHECK: @_ZTVSi = linkonce_odr unnamed_addr constant
+
namespace std {
struct A { A(); };
// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// See Test9 for test description.
+// CHECK: @_ZTTN5Test91BE = linkonce_odr unnamed_addr constant
namespace Test1 {
// Check that we don't initialize the vtable pointer in A::~A(), since the destructor body is trivial.
}
}
+
+namespace Test9 {
+
+// Check that we emit a VTT for B, even though we don't initialize the vtable pointer in the destructor.
+struct A { virtual ~A () { } };
+struct B : virtual A {};
+struct C : virtual B {
+ virtual ~C();
+};
+C::~C() {}
+
+}
// CHECK: call void @_ZN13basic_istreamIcED2Ev
// CHECK: }
-// basic_istream's base dtor is a no-op.
-// CHECK: define linkonce_odr void @_ZN13basic_istreamIcED2Ev(%struct.basic_istream* %this, i8** %vtt) unnamed_addr
-// CHECK-NOT: call
-// CHECK: }
-
// basic_iostream's deleting dtor calls its complete dtor, then
// operator delete().
// CHECK: define linkonce_odr void @_ZN14basic_iostreamIcED0Ev(%struct.basic_iostream* %this) unnamed_addr
// CHECK: define linkonce_odr void @_ZN13basic_istreamIcED0Ev(%struct.basic_istream* %this) unnamed_addr
// CHECK: call void @_ZN13basic_istreamIcED1Ev
// CHECK: call void @_ZdlPv
+
+// basic_istream's base dtor is a no-op.
+// CHECK: define linkonce_odr void @_ZN13basic_istreamIcED2Ev(%struct.basic_istream* %this, i8** %vtt) unnamed_addr
+// CHECK-NOT: call
+// CHECK: }