[cfe-commits] r85916 - in /cfe/trunk: lib/AST/Type.cpp lib/CodeGen/CGVtable.cpp test/CodeGenCXX/virt.cpp
Mike Stump
mrs at apple.com
Tue Nov 3 11:03:17 PST 2009
Author: mrs
Date: Tue Nov 3 13:03:17 2009
New Revision: 85916
URL: http://llvm.org/viewvc/llvm-project?rev=85916&view=rev
Log:
Refine codegen for covariant thunks that return references.
Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CGVtable.cpp
cfe/trunk/test/CodeGenCXX/virt.cpp
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=85916&r1=85915&r2=85916&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Nov 3 13:03:17 2009
@@ -224,6 +224,8 @@
return OPT->getPointeeType();
if (const BlockPointerType *BPT = getAs<BlockPointerType>())
return BPT->getPointeeType();
+ if (const ReferenceType *RT = getAs<ReferenceType>())
+ return RT->getPointeeType();
return QualType();
}
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=85916&r1=85915&r2=85916&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Tue Nov 3 13:03:17 2009
@@ -159,8 +159,8 @@
/// 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 @@
/// 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)
Modified: cfe/trunk/test/CodeGenCXX/virt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virt.cpp?rev=85916&r1=85915&r2=85916&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/virt.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virt.cpp Tue Nov 3 13:03:17 2009
@@ -1113,6 +1113,38 @@
// 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
More information about the cfe-commits
mailing list