move two more lists of protocols over to use ObjCList<ObjCProtocolDecl>,
simplifying code along the way and fixing a problem and memory leak or two.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53876 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 6d19b87..333268e 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -359,9 +359,9 @@
ObjCProtocolDecl *rProto) {
if (lProto == rProto)
return true;
- ObjCProtocolDecl** RefPDecl = rProto->getReferencedProtocols();
- for (unsigned i = 0; i < rProto->getNumReferencedProtocols(); i++)
- if (ProtocolCompatibleWithProtocol(lProto, RefPDecl[i]))
+ for (ObjCProtocolDecl::protocol_iterator PI = rProto->protocol_begin(),
+ E = rProto->protocol_end(); PI != E; ++PI)
+ if (ProtocolCompatibleWithProtocol(lProto, *PI))
return true;
return false;
}
@@ -396,11 +396,10 @@
if (lookupCategory)
for (ObjCCategoryDecl *CDecl = IDecl->getCategoryList(); CDecl;
CDecl = CDecl->getNextClassCategory()) {
- ObjCProtocolDecl **protoList = CDecl->getReferencedProtocols();
- for (unsigned i = 0; i < CDecl->getNumReferencedProtocols(); i++) {
- if (ProtocolCompatibleWithProtocol(lProto, protoList[i]))
+ for (ObjCCategoryDecl::protocol_iterator PI = CDecl->protocol_begin(),
+ E = CDecl->protocol_end(); PI != E; ++PI)
+ if (ProtocolCompatibleWithProtocol(lProto, *PI))
return true;
- }
}
// 3rd, look up the super class(s)