simplify the way ObjCCategoryDecl's get their referenced protocols list
specified.  Previously, the ctor would allocate memory for the list and then
it would get filled in later.  Move the allocation+filling in to be more 
consistent with other stuff, e.g. the addMethods method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48427 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 2ec9395..cd4c6ff 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -68,10 +68,9 @@
 }
 
 ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, SourceLocation L,
-                                           unsigned numRefProtocol, 
                                            IdentifierInfo *Id) {
   void *Mem = C.getAllocator().Allocate<ObjCCategoryDecl>();
-  return new (Mem) ObjCCategoryDecl(L, numRefProtocol, Id);
+  return new (Mem) ObjCCategoryDecl(L, Id);
 }
 
 
@@ -164,6 +163,17 @@
   AtEndLoc = endLoc;
 }
 
+void ObjCCategoryDecl::setReferencedProtocolList(ObjCProtocolDecl **List,
+                                                 unsigned NumRPs) {
+  assert(NumReferencedProtocols == 0 && "Protocol list already set");
+  if (NumRPs == 0) return;
+  
+  ReferencedProtocols = new ObjCProtocolDecl*[NumRPs];
+  memcpy(ReferencedProtocols, List, NumRPs*sizeof(ObjCProtocolDecl*));
+  NumReferencedProtocols = NumRPs;
+}
+
+
 /// addMethods - Insert instance and methods declarations into
 /// ObjCCategoryDecl's CatInsMethods and CatClsMethods fields.
 ///