From 9beac787c17a51a3b1a9b75dcce45f85f057d67c Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Tue, 4 Aug 2009 21:58:42 +0000 Subject: vtable building for simple inheritance. Still in progress. llvm-svn: 78110 --- clang/lib/CodeGen/CGCXX.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen') diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index 21fba145715..97937ea89a1 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/lib/CodeGen/CGCXX.cpp @@ -169,7 +169,7 @@ GetNestedPaths(llvm::SmallVectorImpl &NestedBasePaths, if (i->isVirtual()) continue; const CXXRecordDecl *Base = - cast(i->getType()->getAs()->getDecl()); + cast(i->getType()->getAs()->getDecl()); if (Base == BaseClassDecl) { NestedBasePaths.push_back(BaseClassDecl); return true; @@ -543,6 +543,23 @@ llvm::Value *CodeGenFunction::GenerateVtable(const CXXRecordDecl *RD) { int64_t offset = 0; methods.push_back(m); offset += LLVMPointerWidth; methods.push_back(GenerateRtti(RD)); offset += LLVMPointerWidth; + + for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(), + e = RD->bases_end(); i != e; ++i) { + if (i->isVirtual()) + continue; + const CXXRecordDecl *Base = + cast(i->getType()->getAs()->getDecl()); + for (meth_iter mi = Base->method_begin(), me = Base->method_end(); mi != me; + ++mi) { + if (mi->isVirtual()) { + m = CGM.GetAddrOfFunction(GlobalDecl(*mi)); + m = llvm::ConstantExpr::getBitCast(m, Ptr8Ty); + methods.push_back(m); + } + } + } + for (meth_iter mi = RD->method_begin(), me = RD->method_end(); mi != me; ++mi) { if (mi->isVirtual()) { -- cgit v1.2.3