[cfe-commits] r134015 - in /cfe/trunk/lib: AST/ASTContext.cpp AST/RecordLayoutBuilder.cpp CodeGen/CGObjCMac.cpp CodeGen/CGObjCRuntime.cpp
Fariborz Jahanian
fjahanian at apple.com
Tue Jun 28 11:05:25 PDT 2011
Author: fjahanian
Date: Tue Jun 28 13:05:25 2011
New Revision: 134015
URL: http://llvm.org/viewvc/llvm-project?rev=134015&view=rev
Log:
Eliminate most uses of ShallowCollectObjCIvars which requires
a vector for collection. Use iterators where needed instead.
// rdar://6817577
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=134015&r1=134014&r2=134015&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jun 28 13:05:25 2011
@@ -1089,8 +1089,12 @@
E = OI->ivar_end(); I != E; ++I)
Ivars.push_back(*I);
}
- else
- ShallowCollectObjCIvars(OI, Ivars);
+ else {
+ ObjCInterfaceDecl *IDecl = const_cast<ObjCInterfaceDecl *>(OI);
+ for (ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
+ Iv= Iv->getNextIvar())
+ Ivars.push_back(Iv);
+ }
}
/// CollectInheritedProtocols - Collect all protocols in current class and
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=134015&r1=134014&r2=134015&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Tue Jun 28 13:05:25 2011
@@ -1242,12 +1242,11 @@
}
InitializeLayout(D);
-
+ ObjCInterfaceDecl *OI = const_cast<ObjCInterfaceDecl*>(D);
// Layout each ivar sequentially.
- llvm::SmallVector<ObjCIvarDecl*, 16> Ivars;
- Context.ShallowCollectObjCIvars(D, Ivars);
- for (unsigned i = 0, e = Ivars.size(); i != e; ++i)
- LayoutField(Ivars[i]);
+ for (ObjCIvarDecl *IVD = OI->all_declared_ivar_begin();
+ IVD; IVD = IVD->getNextIvar())
+ LayoutField(IVD);
// 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=134015&r1=134014&r2=134015&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Jun 28 13:05:25 2011
@@ -2410,11 +2410,8 @@
ObjCInterfaceDecl *OID =
const_cast<ObjCInterfaceDecl*>(ID->getClassInterface());
- llvm::SmallVector<ObjCIvarDecl*, 16> OIvars;
- CGM.getContext().ShallowCollectObjCIvars(OID, OIvars);
-
- for (unsigned i = 0, e = OIvars.size(); i != e; ++i) {
- ObjCIvarDecl *IVD = OIvars[i];
+ for (ObjCIvarDecl *IVD = OID->all_declared_ivar_begin();
+ IVD; IVD = IVD->getNextIvar()) {
// Ignore unnamed bit-fields.
if (!IVD->getDeclName())
continue;
@@ -3908,16 +3905,21 @@
!CGM.getLangOptions().ObjCAutoRefCount)
return llvm::Constant::getNullValue(PtrTy);
- llvm::SmallVector<ObjCIvarDecl*, 32> Ivars;
- const ObjCInterfaceDecl *OI = OMD->getClassInterface();
- if (CGM.getLangOptions().ObjCAutoRefCount)
- CGM.getContext().ShallowCollectObjCIvars(OI, Ivars);
- else
+ ObjCInterfaceDecl *OI =
+ const_cast<ObjCInterfaceDecl*>(OMD->getClassInterface());
+ llvm::SmallVector<FieldDecl*, 32> RecFields;
+ if (CGM.getLangOptions().ObjCAutoRefCount) {
+ for (ObjCIvarDecl *IVD = OI->all_declared_ivar_begin();
+ IVD; IVD = IVD->getNextIvar())
+ RecFields.push_back(cast<FieldDecl>(IVD));
+ }
+ else {
+ llvm::SmallVector<ObjCIvarDecl*, 32> Ivars;
CGM.getContext().DeepCollectObjCIvars(OI, true, Ivars);
- llvm::SmallVector<FieldDecl*, 32> RecFields;
- for (unsigned k = 0, e = Ivars.size(); k != e; ++k)
- RecFields.push_back(cast<FieldDecl>(Ivars[k]));
+ for (unsigned k = 0, e = Ivars.size(); k != e; ++k)
+ RecFields.push_back(cast<FieldDecl>(Ivars[k]));
+ }
if (RecFields.empty())
return llvm::Constant::getNullValue(PtrTy);
@@ -5277,17 +5279,14 @@
std::vector<llvm::Constant*> Ivars, Ivar(5);
- const ObjCInterfaceDecl *OID = ID->getClassInterface();
+ ObjCInterfaceDecl *OID =
+ const_cast<ObjCInterfaceDecl*>(ID->getClassInterface());
assert(OID && "CGObjCNonFragileABIMac::EmitIvarList - null interface");
// FIXME. Consolidate this with similar code in GenerateClass.
- // Collect declared and synthesized ivars in a small vector.
- llvm::SmallVector<ObjCIvarDecl*, 16> OIvars;
- CGM.getContext().ShallowCollectObjCIvars(OID, OIvars);
-
- for (unsigned i = 0, e = OIvars.size(); i != e; ++i) {
- ObjCIvarDecl *IVD = OIvars[i];
+ for (ObjCIvarDecl *IVD = OID->all_declared_ivar_begin();
+ IVD; IVD = IVD->getNextIvar()) {
// Ignore unnamed bit-fields.
if (!IVD->getDeclName())
continue;
Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp?rev=134015&r1=134014&r2=134015&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp Tue Jun 28 13:05:25 2011
@@ -52,14 +52,14 @@
// implemented. This should be fixed to get the information from the layout
// directly.
unsigned Index = 0;
- llvm::SmallVector<ObjCIvarDecl*, 16> Ivars;
- CGM.getContext().ShallowCollectObjCIvars(Container, Ivars);
- for (unsigned k = 0, e = Ivars.size(); k != e; ++k) {
- if (Ivar == Ivars[k])
+ ObjCInterfaceDecl *IDecl = const_cast<ObjCInterfaceDecl*>(Container);
+
+ for (ObjCIvarDecl *IVD = IDecl->all_declared_ivar_begin();
+ IVD; IVD = IVD->getNextIvar()) {
+ if (Ivar == IVD)
break;
++Index;
}
- assert(Index != Ivars.size() && "Ivar is not inside container!");
assert(Index < RL->getFieldCount() && "Ivar is not inside record layout!");
return RL->getFieldOffset(Index);
More information about the cfe-commits
mailing list