summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-05-04 05:16:21 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-05-04 05:16:21 +0000
commite993ba6fca045688147321c03f0afff263a925b5 (patch)
tree75b5e602de4bc221de060f9c5967cd03152b4534 /clang/lib/AST
parentff606a12593824aa4533f2f0f2c51d0e93c83b9e (diff)
downloadbcm5719-llvm-e993ba6fca045688147321c03f0afff263a925b5.tar.gz
bcm5719-llvm-e993ba6fca045688147321c03f0afff263a925b5.zip
Add -fobjc-tight-layout.
- This implements gcc style Objective-C interface layout (I think). Currently it is always off, there is no functionality change unless this is passed. For the curious, the deal is that gcc lays out the fields of a subclass as if they were part of the superclass. That is, the subclass fields immediately follow the super class fields instead of being padded to the alignment of the superclass structure. - Currently gcc uses the tight layout in 32-bit and 64-bit modes, and llvm-gcc uses it in 32-bit only, for reasons which aren't clear yet. We probably want to switch to matching gcc, once this makes it through testing... my hope is that we can also fix llvm-gcc in order to maintain compatibility between the compilers. llvm-svn: 70827
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ASTContext.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index d89c8c2b2e3..a9f13c95180 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/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.
OpenPOWER on IntegriCloud