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/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 56a1f81..6d19b87 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -375,9 +375,12 @@
                                     bool RHSIsQualifiedID = false) {
   
   // 1st, look up the class.
-  ObjCProtocolDecl **protoList = IDecl->getReferencedProtocols();
-  for (unsigned i = 0; i < IDecl->getNumIntfRefProtocols(); i++) {
-    if (ProtocolCompatibleWithProtocol(lProto, protoList[i]))
+  const ObjCList<ObjCProtocolDecl> &Protocols =
+    IDecl->getReferencedProtocols();
+
+  for (ObjCList<ObjCProtocolDecl>::iterator PI = Protocols.begin(),
+       E = Protocols.end(); PI != E; ++PI) {
+    if (ProtocolCompatibleWithProtocol(lProto, *PI))
       return true;
     // This is dubious and is added to be compatible with gcc.
     // In gcc, it is also allowed assigning a protocol-qualified 'id'
@@ -385,8 +388,7 @@
     // of protocols in the rhs 'id' object. This IMO, should be a bug.
     // FIXME: Treat this as an extension, and flag this as an error when
     //  GCC extensions are not enabled.
-    else if (RHSIsQualifiedID &&
-             ProtocolCompatibleWithProtocol(protoList[i], lProto))
+    if (RHSIsQualifiedID && ProtocolCompatibleWithProtocol(*PI, lProto))
       return true;
   }
   
@@ -394,7 +396,7 @@
   if (lookupCategory)
     for (ObjCCategoryDecl *CDecl = IDecl->getCategoryList(); CDecl;
          CDecl = CDecl->getNextClassCategory()) {
-      protoList = CDecl->getReferencedProtocols();
+      ObjCProtocolDecl **protoList = CDecl->getReferencedProtocols();
       for (unsigned i = 0; i < CDecl->getNumReferencedProtocols(); i++) {
         if (ProtocolCompatibleWithProtocol(lProto, protoList[i]))
           return true;