aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-08-18 20:50:28 +0000
committerMike Stump <mrs@apple.com>2009-08-18 20:50:28 +0000
commit7c435fa7f7666b22abbe8494c537ebc25209223d (patch)
tree36d36db9957ef56bcbde5df3e1c0112ff6408291 /lib/CodeGen/CGCXX.cpp
parent154440e6a8fa6ac5bca395876d79b530b39a2c1c (diff)
Split out vtable bulding code into a builder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79366 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r--lib/CodeGen/CGCXX.cpp44
1 files changed, 25 insertions, 19 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 655f6f808d..45cb758571 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -703,22 +703,31 @@ llvm::Constant *CodeGenFunction::GenerateRtti(const CXXRecordDecl *RD) {
return Rtti;
}
-void CodeGenFunction::GenerateVcalls(std::vector<llvm::Constant *> &methods,
- const CXXRecordDecl *RD,
- llvm::Type *Ptr8Ty) {
- typedef CXXRecordDecl::method_iterator meth_iter;
- llvm::Constant *m;
-
- // FIXME: audit order
- for (meth_iter mi = RD->method_begin(),
- me = RD->method_end(); mi != me; ++mi) {
- if (mi->isVirtual()) {
- // FIXME: vcall: offset for virtual base for this function
- m = llvm::Constant::getNullValue(Ptr8Ty);
- methods.push_back(m);
+class ABIBuilder {
+ std::vector<llvm::Constant *> &methods;
+ llvm::Type *Ptr8Ty;
+ llvm::LLVMContext &VMContext;
+public:
+ ABIBuilder(llvm::Module &M, std::vector<llvm::Constant *> &meth)
+ : methods(meth), VMContext(M.getContext()) {
+ Ptr8Ty = llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext), 0);
+ }
+ void GenerateVcalls(const CXXRecordDecl *RD) {
+ typedef CXXRecordDecl::method_iterator meth_iter;
+ llvm::Constant *m;
+
+ // FIXME: audit order
+ for (meth_iter mi = RD->method_begin(),
+ me = RD->method_end(); mi != me; ++mi) {
+ if (mi->isVirtual()) {
+ // FIXME: vcall: offset for virtual base for this function
+ m = llvm::Constant::getNullValue(Ptr8Ty);
+ methods.push_back(m);
+ }
}
}
-}
+
+};
void CodeGenFunction::GenerateMethods(std::vector<llvm::Constant *> &methods,
const CXXRecordDecl *RD,
@@ -807,8 +816,9 @@ void CodeGenFunction::GenerateVtableForBase(const CXXRecordDecl *RD,
}
if (forPrimary || ForVirtualBase) {
+ ABIBuilder b(CGM.getModule(), methods);
// then comes the the vcall offsets for all our functions...
- GenerateVcalls(methods, RD, Ptr8Ty);
+ b.GenerateVcalls(RD);
}
bool Top = true;
@@ -822,10 +832,6 @@ void CodeGenFunction::GenerateVtableForBase(const CXXRecordDecl *RD,
PrimaryBaseWasVirtual, IndirectPrimary);
}
- // then come the vcall offsets for all our virtual bases.
- if (!1 && ForVirtualBase)
- GenerateVcalls(methods, RD, Ptr8Ty);
-
if (Top) {
int64_t BaseOffset;
if (ForVirtualBase) {