diff options
author | Chris Lattner <sabre@nondot.org> | 2008-03-16 20:47:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-03-16 20:47:45 +0000 |
commit | 68c82cf61228102aba1194efef222fa1478af2a8 (patch) | |
tree | 494b30fcfa056a98dd5c9958661d1529da69fc9e /lib/Sema/SemaDeclObjC.cpp | |
parent | 61f9d41036e30ff80130f99b31c0626e3ef057cc (diff) |
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
Diffstat (limited to 'lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 7bdfd9e014..e07d3c59e6 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -281,8 +281,7 @@ Sema::DeclTy *Sema::ActOnStartCategoryInterface( ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName); ObjCCategoryDecl *CDecl = - ObjCCategoryDecl::Create(Context, AtInterfaceLoc, NumProtoRefs, - CategoryName); + ObjCCategoryDecl::Create(Context, AtInterfaceLoc, CategoryName); CDecl->setClassInterface(IDecl); /// Check that class of this category is already completely declared. @@ -304,7 +303,8 @@ Sema::DeclTy *Sema::ActOnStartCategoryInterface( } if (NumProtoRefs) { - /// Check then save referenced protocols + llvm::SmallVector<ObjCProtocolDecl*, 32> RefProtocols; + /// Check and then save the referenced protocols. for (unsigned int i = 0; i != NumProtoRefs; i++) { ObjCProtocolDecl* RefPDecl = ObjCProtocols[ProtoRefNames[i]]; if (!RefPDecl || RefPDecl->isForwardDecl()) { @@ -312,10 +312,13 @@ Sema::DeclTy *Sema::ActOnStartCategoryInterface( ProtoRefNames[i]->getName(), CategoryName->getName()); } - CDecl->setCatReferencedProtocols(i, RefPDecl); + if (RefPDecl) + RefProtocols.push_back(RefPDecl); } - CDecl->setLocEnd(EndProtoLoc); + if (!RefProtocols.empty()) + CDecl->setReferencedProtocolList(&RefProtocols[0], RefProtocols.size()); } + CDecl->setLocEnd(EndProtoLoc); return CDecl; } |