]> granicus.if.org Git - clang/commitdiff
Some minor changes toward support of data
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 27 Jul 2009 20:57:45 +0000 (20:57 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 27 Jul 2009 20:57:45 +0000 (20:57 +0000)
member access in the presense of non-virtual bases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77246 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGRecordLayoutBuilder.cpp
lib/CodeGen/CodeGenTypes.cpp
lib/CodeGen/TargetABIInfo.cpp

index 546c5440957c9667154f080df1cac70358dbf791..ed08d347301cc59451dfa20b84bf784469f32e35 100644 (file)
@@ -199,6 +199,10 @@ bool CGRecordLayoutBuilder::LayoutFields(const RecordDecl *D) {
   const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(D);
   
   unsigned FieldNo = 0;
+  // FIXME. This will probably change when virtual bases are supported.
+  if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(D))
+    FieldNo += CXXRD->getNumBases();
+
   for (RecordDecl::field_iterator Field = D->field_begin(), 
        FieldEnd = D->field_end(); Field != FieldEnd; ++Field, ++FieldNo) {
     if (!LayoutField(*Field, Layout.getFieldOffset(FieldNo))) {
index e55ca2ad9cc3198617b569e1ffe3d41d125a9600..e37f7c7751a54837f0ea2fd71e7f70f9fcc317af 100644 (file)
@@ -415,6 +415,21 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
 /// ConvertTagDeclType - Lay out a tagged decl type like struct or union or
 /// enum.
 const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
+
+  // FIXME. This may have to move to a better place.
+  if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(TD)) {
+    assert(!RD->isPolymorphic() &&
+           "FIXME: We don't support polymorphic classes yet!");
+    for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
+         e = RD->bases_end(); i != e; ++i) {
+      if (!i->isVirtual()) {
+        const CXXRecordDecl *Base =
+          cast<CXXRecordDecl>(i->getType()->getAsRecordType()->getDecl());
+        ConvertTagDeclType(Base);
+      }
+    }
+  }
+    
   // TagDecl's are not necessarily unique, instead use the (clang)
   // type connected to the decl.
   const Type *Key = 
index 5c8d5dd230b975210aa5619da786031d6e70cc4b..76d75715bd0e7a5118aeeb08e109092494d32806 100644 (file)
@@ -723,6 +723,10 @@ void X86_64ABIInfo::classify(QualType Ty,
     // Reset Lo class, this will be recomputed.
     Current = NoClass;
     unsigned idx = 0;
+    // FIXME. This will probably change when virtual bases are supported.
+    if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD))
+      idx += CXXRD->getNumBases();
+
     for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
            i != e; ++i, ++idx) {
       uint64_t Offset = OffsetBase + Layout.getFieldOffset(idx);