const CXXRecordDecl *Class,
llvm::Constant *rtti,
std::vector<llvm::Constant *> &methods,
- bool isPrimary) {
+ bool isPrimary,
+ bool ForVirtualBase) {
typedef CXXRecordDecl::method_iterator meth_iter;
llvm::Type *Ptr8Ty;
Ptr8Ty = llvm::PointerType::get(llvm::Type::Int8Ty, 0);
if (RD && !RD->isDynamicClass())
return;
+
+ if (RD && ForVirtualBase)
+ 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);
+ }
+ }
+ if (isPrimary && ForVirtualBase)
+ for (meth_iter mi = Class->method_begin(),
+ me = Class->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);
+ }
+ }
+
if (RD) {
const ASTRecordLayout &Layout = getContext().getASTRecordLayout(Class);
int64_t BaseOffset = -(Layout.getBaseClassOffset(RD) / 8);
return;
// And add the virtuals for the class to the primary vtable.
- RD = Class;
- for (meth_iter mi = RD->method_begin(), me = RD->method_end(); mi != me;
+ for (meth_iter mi = Class->method_begin(), me = Class->method_end(); mi != me;
++mi) {
if (mi->isVirtual()) {
m = CGM.GetAddrOfFunction(GlobalDecl(*mi));
const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (Base != PrimaryBase)
- GenerateVtableForBase(Base, RD, rtti, methods);
+ GenerateVtableForBase(Base, RD, rtti, methods, false, true);
}
llvm::Constant *C;
const CXXRecordDecl *Class,
llvm::Constant *rtti,
std::vector<llvm::Constant *> &methods,
- bool isPrimary = false);
+ bool isPrimary = false,
+ bool ForVirtualBase = false);
llvm::Value *GenerateVtable(const CXXRecordDecl *RD);
void EmitCtorPrologue(const CXXConstructorDecl *CD);
struct D1 {
virtual void bar();
+ virtual void bar2();
+ virtual void bar3();
+ virtual void bar4();
+ virtual void bar5();
void *d1;
};
void D1::bar() { }
// CHECK-LP32: .long __ZTI1F
// CHECK-LP32: .long __ZN1D3booEv
// CHECK-LP32: .long __ZN1F3fooEv
-// CHECK-LP32 .space 4
+// CHECK-LP32: .space 4
+// CHECK-LP32: .space 4
+// CHECK-LP32: .space 4
+// CHECK-LP32: .space 4
+// CHECK-LP32: .space 4
// CHECK-LP32: .long 4294967288
// CHECK-LP32: .long __ZTI1F
// CHECK-LP32: .long __ZN2D13barEv
+// CHECK-LP32: .long __ZN2D14bar2Ev
+// CHECK-LP32: .long __ZN2D14bar3Ev
+// CHECK-LP32: .long __ZN2D14bar4Ev
+// CHECK-LP32: .long __ZN2D14bar5Ev
// CHECK-LP64: __ZTV1F:
// CHECK-LP64 .space 8
// CHECK-LP64: .quad __ZTI1F
// CHECK-LP64: .quad __ZN1D3booEv
// CHECK-LP64: .quad __ZN1F3fooEv
-// CHECK-LP64 .space 8
+// CHECK-LP64: .space 8
+// CHECK-LP64: .space 8
+// CHECK-LP64: .space 8
+// CHECK-LP64: .space 8
+// CHECK-LP64: .space 8
// CHECK-LP64: .quad 18446744073709551600
// CHECK-LP64: .quad __ZTI1F
// CHECK-LP64: .quad __ZN2D13barEv
+// CHECK-LP64: .quad __ZN2D14bar2Ev
+// CHECK-LP64: .quad __ZN2D14bar3Ev
+// CHECK-LP64: .quad __ZN2D14bar4Ev
+// CHECK-LP64: .quad __ZN2D14bar5Ev