[cfe-commits] r70798 - in /cfe/trunk: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/ivar-layout-64.m
Daniel Dunbar
daniel at zuster.org
Sun May 3 14:05:10 PDT 2009
Author: ddunbar
Date: Sun May 3 16:05:10 2009
New Revision: 70798
URL: http://llvm.org/viewvc/llvm-project?rev=70798&view=rev
Log:
Use the implementation decl for looking up offset while building the
ivar layout.
- The layout needs access to synthesized ivars.
Added:
cfe/trunk/test/CodeGenObjC/ivar-layout-64.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=70798&r1=70797&r2=70798&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sun May 3 16:05:10 2009
@@ -821,7 +821,7 @@
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 @@
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 @@
}
/// 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 @@
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 @@
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);
Added: cfe/trunk/test/CodeGenObjC/ivar-layout-64.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/ivar-layout-64.m?rev=70798&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/ivar-layout-64.m (added)
+++ cfe/trunk/test/CodeGenObjC/ivar-layout-64.m Sun May 3 16:05:10 2009
@@ -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
+
+*/
+
+ at interface B @end
+
+ at 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];
+}
+ at end
+
+ at interface A()
+ at property int p0;
+ at property (assign) __strong id p1;
+ at property (assign) __weak id p2;
+ at end
+
+ at implementation A
+ at synthesize p0;
+ at synthesize p1;
+ at synthesize p2;
+ at end
More information about the cfe-commits
mailing list