diff options
-rw-r--r-- | lib/AST/Type.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/CGVtable.cpp | 8 | ||||
-rw-r--r-- | test/CodeGenCXX/virt.cpp | 32 |
3 files changed, 38 insertions, 4 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 65ed767522..3608d34c69 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -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(); } diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp index 3980330670..e2e11478de 100644 --- a/lib/CodeGen/CGVtable.cpp +++ b/lib/CodeGen/CGVtable.cpp @@ -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) diff --git a/test/CodeGenCXX/virt.cpp b/test/CodeGenCXX/virt.cpp index e0067d6c12..4607e6a19a 100644 --- a/test/CodeGenCXX/virt.cpp +++ b/test/CodeGenCXX/virt.cpp @@ -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 |