aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ASTContext.cpp9
-rw-r--r--lib/Driver/Tools.cpp1
2 files changed, 10 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.
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index a714be81c3..2a959b3c55 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -466,6 +466,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_fobjc_gc);
// FIXME: Should we remove this?
Args.AddLastArg(CmdArgs, options::OPT_fobjc_nonfragile_abi);
+ Args.AddLastArg(CmdArgs, options::OPT_fobjc_tight_layout);
Args.AddLastArg(CmdArgs, options::OPT_fprint_source_range_info);
Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_print_source_range_info);
Args.AddLastArg(CmdArgs, options::OPT_ftime_report);