aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index d89c8c2b2e..a9f13c9518 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -654,6 +654,9 @@ void ASTRecordLayout::LayoutField(const FieldDecl *FD, unsigned FieldNo,
Size = FieldOffset + FieldSize;
}
+ // Remember the next available offset.
+ NextOffset = Size;
+
// Remember max struct/class alignment.
Alignment = std::max(Alignment, FieldAlign);
}
@@ -718,6 +721,12 @@ ASTContext::getObjCLayout(const ObjCInterfaceDecl *D,
unsigned Alignment = SL.getAlignment();
uint64_t Size = SL.getSize();
+ // If we are using tight interface packing, then we start laying
+ // out ivars not at the end of the superclass structure, but at
+ // the next byte following the last field.
+ if (getLangOptions().ObjCTightLayout)
+ Size = llvm::RoundUpToAlignment(SL.NextOffset, 8);
+
ObjCLayouts[Key] = NewEntry = new ASTRecordLayout(Size, Alignment);
NewEntry->InitializeLayout(FieldCount);
// Super class is at the beginning of the layout.