[cfe-commits] r124967 - in /cfe/trunk: lib/CodeGen/CGVTables.cpp lib/CodeGen/CodeGenModule.h test/CodeGenCXX/vtable-available-externally.cpp
Anders Carlsson
andersca at mac.com
Sat Feb 5 10:48:56 PST 2011
Author: andersca
Date: Sat Feb 5 12:48:55 2011
New Revision: 124967
URL: http://llvm.org/viewvc/llvm-project?rev=124967&view=rev
Log:
Pass a 'ForVTable' flag to GetAddrOfThunk and pass it along to GetOrCreateLLVMFunction so that we
won't assert when building a thunk for an implicit virtual member function that is not marked used.
Modified:
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp
Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=124967&r1=124966&r2=124967&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Sat Feb 5 12:48:55 2011
@@ -2451,7 +2451,8 @@
}
llvm::Constant *CodeGenModule::GetAddrOfThunk(GlobalDecl GD,
- const ThunkInfo &Thunk) {
+ const ThunkInfo &Thunk,
+ bool ForVTable) {
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
// Compute the mangled name.
@@ -2463,7 +2464,7 @@
getCXXABI().getMangleContext().mangleThunk(MD, Thunk, Name);
const llvm::Type *Ty = getTypes().GetFunctionTypeForVTable(GD);
- return GetOrCreateLLVMFunction(Name, Ty, GD, /*ForVTable=*/false);
+ return GetOrCreateLLVMFunction(Name, Ty, GD, ForVTable);
}
static llvm::Value *PerformTypeAdjustment(CodeGenFunction &CGF,
@@ -2681,7 +2682,7 @@
void CodeGenVTables::EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk)
{
- llvm::Constant *Entry = CGM.GetAddrOfThunk(GD, Thunk);
+ llvm::Constant *Entry = CGM.GetAddrOfThunk(GD, Thunk, /*ForVTable=*/false);
// Strip off a bitcast if we got one back.
if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(Entry)) {
@@ -2701,7 +2702,7 @@
// Remove the name from the old thunk function and get a new thunk.
OldThunkFn->setName(llvm::StringRef());
- Entry = CGM.GetAddrOfThunk(GD, Thunk);
+ Entry = CGM.GetAddrOfThunk(GD, Thunk, /*ForVTable=*/false);
// If needed, replace the old thunk with a bitcast.
if (!OldThunkFn->use_empty()) {
@@ -2912,7 +2913,7 @@
VTableThunks[NextVTableThunkIndex].first == I) {
const ThunkInfo &Thunk = VTableThunks[NextVTableThunkIndex].second;
- Init = CGM.GetAddrOfThunk(GD, Thunk);
+ Init = CGM.GetAddrOfThunk(GD, Thunk, /*ForVTable=*/true);
NextVTableThunkIndex++;
} else {
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=124967&r1=124966&r2=124967&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Sat Feb 5 12:48:55 2011
@@ -325,7 +325,8 @@
llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);
/// GetAddrOfThunk - Get the address of the thunk for the given global decl.
- llvm::Constant *GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk);
+ llvm::Constant *GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk,
+ bool ForVTable);
/// GetWeakRefReference - Get a reference to the target of VD.
llvm::Constant *GetWeakRefReference(const ValueDecl *VD);
Modified: cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp?rev=124967&r1=124966&r2=124967&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp Sat Feb 5 12:48:55 2011
@@ -118,3 +118,29 @@
B::~B() { }
}
+
+// Check that we don't assert on this test.
+namespace Test6 {
+
+struct A {
+ virtual ~A();
+ int a;
+};
+
+struct B {
+ virtual ~B();
+ int b;
+};
+
+struct C : A, B {
+ C();
+};
+
+struct D : C {
+ virtual void f();
+ D();
+};
+
+D::D() { }
+
+}
More information about the cfe-commits
mailing list