diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 6 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 13 |
2 files changed, 7 insertions, 12 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a9f13c95180..a947fea95aa 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -713,10 +713,6 @@ ASTContext::getObjCLayout(const ObjCInterfaceDecl *D, ASTRecordLayout *NewEntry = NULL; if (ObjCInterfaceDecl *SD = D->getSuperClass()) { - // FIXME: This increment of FieldCount is wrong, we don't actually - // count the super class as a member (see the field index passed - // to LayoutField below). - FieldCount++; const ASTRecordLayout &SL = getASTObjCInterfaceLayout(SD); unsigned Alignment = SL.getAlignment(); uint64_t Size = SL.getSize(); @@ -729,8 +725,6 @@ ASTContext::getObjCLayout(const ObjCInterfaceDecl *D, ObjCLayouts[Key] = NewEntry = new ASTRecordLayout(Size, Alignment); NewEntry->InitializeLayout(FieldCount); - // Super class is at the beginning of the layout. - NewEntry->SetFieldOffset(0, 0); } else { ObjCLayouts[Key] = NewEntry = new ASTRecordLayout(); NewEntry->InitializeLayout(FieldCount); diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 1a1ef831232..1f58389ab85 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -4222,13 +4222,14 @@ void CGObjCNonFragileABIMac::GetClassSizeInfo(const ObjCImplementationDecl *OID, const ASTRecordLayout &RL = CGM.getContext().getASTObjCImplementationLayout(OID); - if (!RL.getFieldCount()) { - InstanceStart = InstanceSize = 0; - return; - } - - InstanceStart = RL.getFieldOffset(0) / 8; + // InstanceSize is really instance end. InstanceSize = llvm::RoundUpToAlignment(RL.getNextOffset(), 8) / 8; + + // If there are no fields, the start is the same as the end. + if (!RL.getFieldCount()) + InstanceStart = InstanceSize; + else + InstanceStart = RL.getFieldOffset(0) / 8; } void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { |