Action::DeclTy *
Sema::ActOnForwardProtocolDeclaration(Scope *S, SourceLocation AtProtocolLoc,
IdentifierInfo **IdentList, unsigned NumElts) {
- ObjcForwardProtocolDecl *FDecl = new ObjcForwardProtocolDecl(AtProtocolLoc,
- NumElts);
+ llvm::SmallVector<ObjcProtocolDecl*, 32> Protocols;
for (unsigned i = 0; i != NumElts; ++i) {
- ObjcProtocolDecl *PDecl;
- PDecl = getObjCProtocolDecl(S, IdentList[i], AtProtocolLoc);
- if (!PDecl) {// Already seen?
+ ObjcProtocolDecl *PDecl = getObjCProtocolDecl(S, IdentList[i],
+ AtProtocolLoc);
+ if (!PDecl) { // Already seen?
PDecl = new ObjcProtocolDecl(SourceLocation(), 0, IdentList[i], true);
// Chain & install the protocol decl into the identifier.
PDecl->setNext(IdentList[i]->getFETokenInfo<ScopedDecl>());
// Remember that this needs to be removed when the scope is popped.
S->AddDecl(IdentList[i]);
- FDecl->setForwardProtocolDecl((int)i, PDecl);
+ Protocols.push_back(PDecl);
}
- return FDecl;
+ return new ObjcForwardProtocolDecl(AtProtocolLoc,
+ &Protocols[0], Protocols.size());
}
Sema::DeclTy *Sema::ActOnStartCategoryInterface(Scope* S,
ObjcProtocolDecl **ReferencedProtocols;
unsigned NumReferencedProtocols;
public:
- ObjcForwardProtocolDecl(SourceLocation L, unsigned nElts)
+ ObjcForwardProtocolDecl(SourceLocation L,
+ ObjcProtocolDecl **Elts, unsigned nElts)
: TypeDecl(ObjcForwardProtocol, L, 0, 0) {
+ NumReferencedProtocols = nElts;
if (nElts) {
ReferencedProtocols = new ObjcProtocolDecl*[nElts];
- memset(ReferencedProtocols, '\0', nElts*sizeof(ObjcProtocolDecl*));
- NumReferencedProtocols = nElts;
+ memcpy(ReferencedProtocols, Elts, nElts*sizeof(ObjcProtocolDecl*));
} else {
ReferencedProtocols = 0;
}
return ReferencedProtocols[idx];
}
-
static bool classof(const Decl *D) {
return D->getKind() == ObjcForwardProtocol;
}