Add MicrosoftVFTableContext to AST
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187409 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp
index 9c4a5e0..c7bb54e 100644
--- a/lib/CodeGen/CGVTables.cpp
+++ b/lib/CodeGen/CGVTables.cpp
@@ -29,7 +29,14 @@
using namespace CodeGen;
CodeGenVTables::CodeGenVTables(CodeGenModule &CGM)
- : CGM(CGM), VTContext(CGM.getContext()) { }
+ : CGM(CGM), VTContext(CGM.getContext()) {
+ if (CGM.getTarget().getCXXABI().isMicrosoft()) {
+ // FIXME: Eventually, we should only have one of V*TContexts available.
+ // Today we use both in the Microsoft ABI as MicrosoftVFTableContext
+ // is not completely supported in CodeGen yet.
+ VFTContext.reset(new MicrosoftVFTableContext(CGM.getContext()));
+ }
+}
llvm::Constant *CodeGenModule::GetAddrOfThunk(GlobalDecl GD,
const ThunkInfo &Thunk) {
@@ -389,6 +396,11 @@
void CodeGenVTables::EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk,
bool UseAvailableExternallyLinkage)
{
+ if (CGM.getTarget().getCXXABI().isMicrosoft()) {
+ // Emission of thunks is not supported yet in Microsoft ABI.
+ return;
+ }
+
const CGFunctionInfo &FnInfo = CGM.getTypes().arrangeGlobalDeclaration(GD);
// FIXME: re-use FnInfo in this computation.
@@ -485,6 +497,12 @@
if (isa<CXXDestructorDecl>(MD) && GD.getDtorType() == Dtor_Base)
return;
+ if (VFTContext.isValid()) {
+ // FIXME: This is a temporary solution to force generation of vftables in
+ // Microsoft ABI. Remove when we thread VFTableContext through CodeGen.
+ VFTContext->getVFPtrOffsets(MD->getParent());
+ }
+
const VTableContext::ThunkInfoVectorTy *ThunkInfoVector =
VTContext.getThunkInfo(MD);
if (!ThunkInfoVector)
@@ -804,6 +822,12 @@
void
CodeGenVTables::GenerateClassData(const CXXRecordDecl *RD) {
+ if (VFTContext.isValid()) {
+ // FIXME: This is a temporary solution to force generation of vftables in
+ // Microsoft ABI. Remove when we thread VFTableContext through CodeGen.
+ VFTContext->getVFPtrOffsets(RD);
+ }
+
// First off, check whether we've already emitted the v-table and
// associated stuff.
llvm::GlobalVariable *VTable = GetAddrOfVTable(RD);