[cfe-commits] r68122 - in /cfe/trunk: lib/AST/ASTContext.cpp lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/synthesize_ivar.m
Fariborz Jahanian
fjahanian at apple.com
Tue Mar 31 11:11:25 PDT 2009
Author: fjahanian
Date: Tue Mar 31 13:11:23 2009
New Revision: 68122
URL: http://llvm.org/viewvc/llvm-project?rev=68122&view=rev
Log:
ir-gen support for nonfragile abi's synthesized ivars.
Added:
cfe/trunk/test/CodeGenObjC/synthesize_ivar.m
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=68122&r1=68121&r2=68122&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Mar 31 13:11:23 2009
@@ -705,6 +705,12 @@
const ObjCIvarDecl* Ivar = (*IVI);
NewEntry->LayoutField(Ivar, i++, false, StructPacking, *this);
}
+ // Also synthesized ivars
+ for (ObjCInterfaceDecl::prop_iterator I = D->prop_begin(),
+ E = D->prop_end(); I != E; ++I) {
+ if (ObjCIvarDecl *Ivar = (*I)->getPropertyIvarDecl())
+ NewEntry->LayoutField(Ivar, i++, false, StructPacking, *this);
+ }
// Finally, round the size of the total struct up to the alignment of the
// struct itself.
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=68122&r1=68121&r2=68122&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Mar 31 13:11:23 2009
@@ -1673,6 +1673,12 @@
for (ObjCInterfaceDecl::ivar_iterator I = OI->ivar_begin(),
E = OI->ivar_end(); I != E; ++I)
++count;
+ // look into properties.
+ for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(),
+ E = OI->prop_end(); I != E; ++I) {
+ if ((*I)->getPropertyIvarDecl())
+ ++count;
+ }
return count;
}
@@ -4559,13 +4565,20 @@
RecordDecl::field_iterator i,p;
const RecordDecl *RD = GetFirstIvarInRecord(OID, i,p);
- ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin();
-
+ // collect declared and synthesized ivars in a small vector.
+ llvm::SmallVector<ObjCIvarDecl*, 16> OIvars;
+ for (ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin(),
+ E = OID->ivar_end(); I != E; ++I)
+ OIvars.push_back(*I);
+ for (ObjCInterfaceDecl::prop_iterator I = OID->prop_begin(),
+ E = OID->prop_end(); I != E; ++I)
+ if (ObjCIvarDecl *IV = (*I)->getPropertyIvarDecl())
+ OIvars.push_back(IV);
+ unsigned iv = 0;
for (RecordDecl::field_iterator e = RD->field_end(); i != e; ++i) {
FieldDecl *Field = *i;
uint64_t offset = GetIvarBaseOffset(Layout, Field);
- const ObjCIvarDecl *ivarDecl = *I++;
- Ivar[0] = EmitIvarOffsetVar(ID->getClassInterface(), ivarDecl, offset);
+ Ivar[0] = EmitIvarOffsetVar(ID->getClassInterface(), OIvars[iv++], offset);
if (Field->getIdentifier())
Ivar[1] = GetMethodVarName(Field->getIdentifier());
else
Added: cfe/trunk/test/CodeGenObjC/synthesize_ivar.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/synthesize_ivar.m?rev=68122&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/synthesize_ivar.m (added)
+++ cfe/trunk/test/CodeGenObjC/synthesize_ivar.m Tue Mar 31 13:11:23 2009
@@ -0,0 +1,14 @@
+// RUN: clang-cc -arch x86_64 -emit-llvm -o %t %s
+
+ at interface I
+{
+}
+ at property int IP;
+ at end
+
+ at implementation I
+ at synthesize IP;
+- (int) Meth {
+ return IP;
+}
+ at end
More information about the cfe-commits
mailing list