]> granicus.if.org Git - clang/commitdiff
Eliminate most uses of ShallowCollectObjCIvars which requires
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 28 Jun 2011 18:05:25 +0000 (18:05 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 28 Jun 2011 18:05:25 +0000 (18:05 +0000)
a vector for collection. Use iterators where needed instead.
// rdar://6817577

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134015 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
lib/AST/RecordLayoutBuilder.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CGObjCRuntime.cpp

index a653e60efec0ec9560f0248c3432234206031ae1..544fc1ababfa55ef26dee570ed3e06a4a5f0671b 100644 (file)
@@ -1089,8 +1089,12 @@ void ASTContext::DeepCollectObjCIvars(const ObjCInterfaceDecl *OI,
          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
index de0b1d0ed9dbde3995ab29fbea0e3a6f2936fa3f..5636a6f0f64a9539c5c56ae0dc014dd703187c21 100644 (file)
@@ -1242,12 +1242,11 @@ void RecordLayoutBuilder::Layout(const ObjCInterfaceDecl *D) {
   }
 
   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.
index d518372f9c99f40c15adac3a83e65ec8dd800b32..98cd57155d77df6db4272064767e20059f03a056 100644 (file)
@@ -2410,11 +2410,8 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID,
   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 @@ llvm::Constant *CGObjCCommonMac::BuildIvarLayout(
       !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 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(
 
   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;
index 6ce1cb943533f49f2057a2b42b009ddf25cf3ed5..0734e74d57a787f592cb37c349fcc6a3bf5633a5 100644 (file)
@@ -52,14 +52,14 @@ static uint64_t LookupFieldBitOffset(CodeGen::CodeGenModule &CGM,
   // 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);