CodeGen: Clean up implementation of vtable initializer builder. NFC.
- Simplify signature of CreateVTableInitializer function.
- Move vtable component builder to a separate function.
- Remove unnecessary accessors from VTableLayout class.
This is in preparation for a future change that will alter the type of the
vtable initializer.
Differential Revision: https://reviews.llvm.org/D22642
llvm-svn: 280897
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index ecf4d04..bd9e882 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1462,9 +1462,7 @@
CGM.GetAddrOfRTTIDescriptor(CGM.getContext().getTagDeclType(RD));
// Create and set the initializer.
- llvm::Constant *Init = CGVT.CreateVTableInitializer(
- RD, VTLayout.vtable_component_begin(), VTLayout.getNumVTableComponents(),
- VTLayout.vtable_thunk_begin(), VTLayout.getNumVTableThunks(), RTTI);
+ llvm::Constant *Init = CGVT.CreateVTableInitializer(VTLayout, RTTI);
VTable->setInitializer(Init);
// Set the correct linkage.
@@ -1575,7 +1573,7 @@
ItaniumVTableContext &VTContext = CGM.getItaniumVTableContext();
llvm::ArrayType *ArrayType = llvm::ArrayType::get(
- CGM.Int8PtrTy, VTContext.getVTableLayout(RD).getNumVTableComponents());
+ CGM.Int8PtrTy, VTContext.getVTableLayout(RD).vtable_components().size());
VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
Name, ArrayType, llvm::GlobalValue::ExternalLinkage);