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/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index 4e909fc..efeb9be 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -248,18 +248,16 @@
Out << "@interface " << I;
// Protocols?
- int count = OID->getNumIntfRefProtocols();
-
- if (count > 0) {
- ObjCProtocolDecl **refProtocols = OID->getReferencedProtocols();
- for (int i = 0; i < count; i++)
- Out << (i == 0 ? '<' : ',') << refProtocols[i]->getName();
+ const ObjCList<ObjCProtocolDecl> &Protocols = OID->getReferencedProtocols();
+ if (!Protocols.empty()) {
+ for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
+ E = Protocols.end(); I != E; ++I)
+ Out << (I == Protocols.begin() ? '<' : ',') << (*I)->getName();
}
- if (count > 0)
- Out << ">\n";
- else
- Out << '\n';
+ if (!Protocols.empty())
+ Out << ">";
+ Out << '\n';
if (OID->ivar_size() > 0) {
Out << '{';