diff options
author | Anders Carlsson <andersca@mac.com> | 2010-05-18 16:51:41 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-05-18 16:51:41 +0000 |
commit | a83fb4bf8119b980ccf7de0795dff250a799ea58 (patch) | |
tree | b81c617a50f022bebbf18b771fbd6f6c61e1d768 /lib/CodeGen/CGRecordLayoutBuilder.cpp | |
parent | d0785ea6c4c37a7fa4fcd4840e6e036ffb44e13e (diff) |
Correctly initialize bases with member pointers. This should fix PR6441 but that test case is a bit weird and I'd like to investigate further before closing that bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104025 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGRecordLayoutBuilder.cpp')
-rw-r--r-- | lib/CodeGen/CGRecordLayoutBuilder.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index b1a2d51b66..c93e093a43 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -118,6 +118,7 @@ private: /// CheckForPointerToDataMember - Check if the given type contains a pointer /// to data member. void CheckForPointerToDataMember(QualType T); + void CheckForPointerToDataMember(const CXXRecordDecl *RD); public: CGRecordLayoutBuilder(CodeGenTypes &Types) @@ -456,6 +457,8 @@ void CGRecordLayoutBuilder::LayoutNonVirtualBase(const CXXRecordDecl *BaseDecl, return; } + CheckForPointerToDataMember(BaseDecl); + // FIXME: Actually use a better type than [sizeof(BaseDecl) x i8] when we can. AppendPadding(BaseOffset / 8, 1); @@ -618,15 +621,24 @@ void CGRecordLayoutBuilder::CheckForPointerToDataMember(QualType T) { } else if (const RecordType *RT = T->getAs<RecordType>()) { const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl()); - // FIXME: It would be better if there was a way to explicitly compute the - // record layout instead of converting to a type. - Types.ConvertTagDeclType(RD); + return CheckForPointerToDataMember(RD); + } +} - const CGRecordLayout &Layout = Types.getCGRecordLayout(RD); +void +CGRecordLayoutBuilder::CheckForPointerToDataMember(const CXXRecordDecl *RD) { + // This record already contains a member pointer. + if (ContainsPointerToDataMember) + return; - if (Layout.containsPointerToDataMember()) - ContainsPointerToDataMember = true; - } + // FIXME: It would be better if there was a way to explicitly compute the + // record layout instead of converting to a type. + Types.ConvertTagDeclType(RD); + + const CGRecordLayout &Layout = Types.getCGRecordLayout(RD); + + if (Layout.containsPointerToDataMember()) + ContainsPointerToDataMember = true; } CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D) { |