From 8f5645cd518a31e7de9401543a4a75057bb1947e Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Fri, 6 Jun 2008 02:14:01 +0000 Subject: During interface layout, don't forget super class. llvm-svn: 52035 --- clang/lib/AST/ASTContext.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'clang/lib/AST/ASTContext.cpp') diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4a1fb39bb60..d8e2c06fc03 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -405,10 +405,22 @@ ASTContext::getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) { // Allocate and assign into ASTRecordLayouts here. The "Entry" reference can // be invalidated (dangle) if the ASTRecordLayouts hashtable is inserted into. - ASTRecordLayout *NewEntry = new ASTRecordLayout(); + ASTRecordLayout *NewEntry = NULL; + unsigned FieldCount = D->ivar_size(); + if (ObjCInterfaceDecl *SD = D->getSuperClass()) { + FieldCount++; + const ASTRecordLayout &SL = getASTObjCInterfaceLayout(SD); + unsigned Alignment = SL.getAlignment(); + uint64_t Size = SL.getSize(); + NewEntry = new ASTRecordLayout(Size, Alignment); + NewEntry->InitializeLayout(FieldCount); + NewEntry->SetFieldOffset(0, 0); // Super class is at the beginning of the layout. + } else { + NewEntry = new ASTRecordLayout(); + NewEntry->InitializeLayout(FieldCount); + } Entry = NewEntry; - NewEntry->InitializeLayout(D->ivar_size()); bool IsPacked = D->getAttr(); if (const AlignedAttr *AA = D->getAttr()) -- cgit v1.2.3