Refine codegen for covariant thunks that return references.

llvm-svn: 85916
This commit is contained in:
Mike Stump 2009-11-03 19:03:17 +00:00
parent 76a4774a0d
commit 4627132ebc
3 changed files with 38 additions and 4 deletions

View File

@ -224,6 +224,8 @@ QualType Type::getPointeeType() const {
return OPT->getPointeeType();
if (const BlockPointerType *BPT = getAs<BlockPointerType>())
return BPT->getPointeeType();
if (const ReferenceType *RT = getAs<ReferenceType>())
return RT->getPointeeType();
return QualType();
}

View File

@ -159,8 +159,8 @@ public:
/// getNVOffset - Returns the non-virtual offset for the given (B) base of the
/// derived class D.
Index_t getNVOffset(QualType qB, QualType qD) {
qD = qD->getAs<PointerType>()->getPointeeType();
qB = qB->getAs<PointerType>()->getPointeeType();
qD = qD->getPointeeType();
qB = qB->getPointeeType();
CXXRecordDecl *D = cast<CXXRecordDecl>(qD->getAs<RecordType>()->getDecl());
CXXRecordDecl *B = cast<CXXRecordDecl>(qB->getAs<RecordType>()->getDecl());
int64_t o = getNVOffset_1(D, B);
@ -174,8 +174,8 @@ public:
/// getVbaseOffset - Returns the index into the vtable for the virtual base
/// offset for the given (B) virtual base of the derived class D.
Index_t getVbaseOffset(QualType qB, QualType qD) {
qD = qD->getAs<PointerType>()->getPointeeType();
qB = qB->getAs<PointerType>()->getPointeeType();
qD = qD->getPointeeType();
qB = qB->getPointeeType();
CXXRecordDecl *D = cast<CXXRecordDecl>(qD->getAs<RecordType>()->getDecl());
CXXRecordDecl *B = cast<CXXRecordDecl>(qB->getAs<RecordType>()->getDecl());
if (D != Class)

View File

@ -1113,6 +1113,38 @@ class test17_D : public test17_B2 {
// CHECK-LP64-NEXT: .quad __ZN9test17_B13barEv
struct test18_NV1 {
virtual void fooNV1() { }
virtual void foo_NV1() { }
int i;
};
struct test18_NV2 {
virtual test18_NV2& foo1() { return *this; }
virtual void foo_NV2() { }
virtual void foo_NV2b() { }
int i;
};
struct test18_B : public test18_NV1, test18_NV2 {
virtual test18_B& foo1() { return *this; }
virtual test18_B *foo2() { return 0; }
virtual test18_B *foo3() { return 0; }
virtual void foo_B() { }
int i;
};
struct test18_B2 : test18_NV1, virtual test18_B {
virtual test18_B2& foo1() { return *this; }
virtual test18_B2 *foo2() { return 0; }
virtual void foo_B2() { }
int i;
};
struct test18_D : test18_NV1, virtual test18_B2 {
virtual test18_D& foo1() { return *this; }
} d;
// CHECK-LP64: __ZTV1B:
// CHECK-LP64-NEXT: .space 8