aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-05-03 21:05:10 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-05-03 21:05:10 +0000
commit5a5a803df8a8e3e567278fdfd8a6c1aff8dc6b82 (patch)
tree3da6d11a6d34a5425b60e95951112cece7f2934c
parenta74869c46a02ad7c609403b402884ab46586eb76 (diff)
Use the implementation decl for looking up offset while building the
ivar layout. - The layout needs access to synthesized ivars. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70798 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGObjCMac.cpp10
-rw-r--r--test/CodeGenObjC/ivar-layout-64.m45
2 files changed, 50 insertions, 5 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index a5450ff1be..5d4b65f470 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -821,7 +821,7 @@ protected:
void BuildAggrIvarRecordLayout(const RecordType *RT,
unsigned int BytePos, bool ForStrongLayout,
bool &HasUnion);
- void BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
+ void BuildAggrIvarLayout(const ObjCImplementationDecl *OI,
const llvm::StructLayout *Layout,
const RecordDecl *RD,
const llvm::SmallVectorImpl<FieldDecl*> &RecFields,
@@ -846,7 +846,7 @@ protected:
llvm::Constant *GetProtocolRef(const ObjCProtocolDecl *PD);
/// GetFieldBaseOffset - return's field byte offset.
- uint64_t GetFieldBaseOffset(const ObjCInterfaceDecl *OI,
+ uint64_t GetFieldBaseOffset(const ObjCImplementationDecl *OI,
const llvm::StructLayout *Layout,
const FieldDecl *Field);
@@ -2229,7 +2229,7 @@ llvm::Function *CGObjCCommonMac::GenerateMethod(const ObjCMethodDecl *OMD,
}
/// GetFieldBaseOffset - return the field's byte offset.
-uint64_t CGObjCCommonMac::GetFieldBaseOffset(const ObjCInterfaceDecl *OI,
+uint64_t CGObjCCommonMac::GetFieldBaseOffset(const ObjCImplementationDecl *OI,
const llvm::StructLayout *Layout,
const FieldDecl *Field) {
// Is this a C struct?
@@ -2935,7 +2935,7 @@ void CGObjCCommonMac::BuildAggrIvarRecordLayout(const RecordType *RT,
ForStrongLayout, HasUnion);
}
-void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
+void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI,
const llvm::StructLayout *Layout,
const RecordDecl *RD,
const llvm::SmallVectorImpl<FieldDecl*> &RecFields,
@@ -3109,7 +3109,7 @@ llvm::Constant *CGObjCCommonMac::BuildIvarLayout(
SkipIvars.clear();
IvarsInfo.clear();
- BuildAggrIvarLayout(OI, 0, 0, RecFields, 0, ForStrongLayout, hasUnion);
+ BuildAggrIvarLayout(OMD, 0, 0, RecFields, 0, ForStrongLayout, hasUnion);
if (IvarsInfo.empty())
return llvm::Constant::getNullValue(PtrTy);
diff --git a/test/CodeGenObjC/ivar-layout-64.m b/test/CodeGenObjC/ivar-layout-64.m
new file mode 100644
index 0000000000..894dbfed89
--- /dev/null
+++ b/test/CodeGenObjC/ivar-layout-64.m
@@ -0,0 +1,45 @@
+// RUNX: llvm-gcc -m64 -fobjc-gc -emit-llvm -S -o %t %s &&
+// RUN: clang-cc -triple x86_64-apple-darwin9 -fobjc-gc -emit-llvm -o %t %s &&
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"A\\00"' %t &&
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"\\11q\\10\\00"' %t &&
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"!q\\00"' %t &&
+// RUN: true
+
+/*
+
+Here is a handy command for looking at llvm-gcc's output:
+llvm-gcc -m64 -fobjc-gc -emit-llvm -S -o - ivar-layout-64.m | \
+ grep 'OBJC_CLASS_NAME.* =.*global' | \
+ sed -e 's#, section.*# ...#' | \
+ sort
+
+*/
+
+@interface B @end
+
+@interface A {
+ struct s0 {
+ int f0;
+ int f1;
+ } f0;
+ id f1;
+__weak B *f2;
+ int f3 : 5;
+ struct s1 {
+ int *f0;
+ int *f1;
+ } f4[2][1];
+}
+@end
+
+@interface A()
+@property int p0;
+@property (assign) __strong id p1;
+@property (assign) __weak id p2;
+@end
+
+@implementation A
+@synthesize p0;
+@synthesize p1;
+@synthesize p2;
+@end