introduce a new ObjCList templated class and start moving 
various objc lists over to it.  First up, the protocol list 
on ObjCInterfaceDecl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53856 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 20afc5e..b9c1542 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -415,9 +415,11 @@
 
   // Collect the names of referenced protocols
   llvm::SmallVector<std::string, 16> Protocols;
-  ObjCInterfaceDecl * ClassDecl = (ObjCInterfaceDecl*)OCD->getClassInterface();
-  for (unsigned i=0 ; i<ClassDecl->getNumIntfRefProtocols() ; i++)
-    Protocols.push_back(ClassDecl->getReferencedProtocols()[i]->getName());
+  const ObjCInterfaceDecl *ClassDecl = OCD->getClassInterface();
+  const ObjCList<ObjCProtocolDecl> &Protos =ClassDecl->getReferencedProtocols();
+  for (ObjCList<ObjCProtocolDecl>::iterator I = Protos.begin(),
+       E = Protos.end(); I != E; ++I)
+    Protocols.push_back((*I)->getName());
 
   // Generate the category
   Runtime->GenerateCategory(OCD->getClassInterface()->getName(),
@@ -495,8 +497,10 @@
   }
   // Collect the names of referenced protocols
   llvm::SmallVector<std::string, 16> Protocols;
-  for (unsigned i = 0, e = ClassDecl->getNumIntfRefProtocols() ; i < e ; i++)
-    Protocols.push_back(ClassDecl->getReferencedProtocols()[i]->getName());
+  const ObjCList<ObjCProtocolDecl> &Protos =ClassDecl->getReferencedProtocols();
+  for (ObjCList<ObjCProtocolDecl>::iterator I = Protos.begin(),
+       E = Protos.end(); I != E; ++I)
+    Protocols.push_back((*I)->getName());
 
   // Generate the category
   Runtime->GenerateClass(ClassName, SCName, instanceSize, IvarNames, IvarTypes,