diff options
-rw-r--r-- | include/clang/Parse/Action.h | 19 | ||||
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 15 | ||||
-rw-r--r-- | lib/Sema/Sema.h | 15 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 21 |
4 files changed, 28 insertions, 42 deletions
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index 7ffbbfaf9c..d2a653d239 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -648,22 +648,21 @@ public: virtual DeclTy *ActOnStartProtocolInterface(SourceLocation AtProtoLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, - DeclTy * const *ProtoRefNames, + DeclTy * const *ProtoRefs, unsigned NumProtoRefs, SourceLocation EndProtoLoc) { return 0; } // ActOnStartCategoryInterface - this action is called immdiately after // parsing the prologue for a category interface. - virtual DeclTy *ActOnStartCategoryInterface( - SourceLocation AtInterfaceLoc, - IdentifierInfo *ClassName, - SourceLocation ClassLoc, - IdentifierInfo *CategoryName, - SourceLocation CategoryLoc, - const IdentifierLocPair *ProtoRefNames, - unsigned NumProtoRefs, - SourceLocation EndProtoLoc) { + virtual DeclTy *ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, + IdentifierInfo *ClassName, + SourceLocation ClassLoc, + IdentifierInfo *CategoryName, + SourceLocation CategoryLoc, + DeclTy * const *ProtoRefs, + unsigned NumProtoRefs, + SourceLocation EndProtoLoc) { return 0; } // ActOnStartClassImplementation - this action is called immdiately after diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 1bfc2a949b..cabb5bf69a 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -131,7 +131,6 @@ Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration( SourceLocation lparenLoc = ConsumeParen(); SourceLocation categoryLoc, rparenLoc; IdentifierInfo *categoryId = 0; - llvm::SmallVector<IdentifierLocPair, 8> ProtocolRefs; // For ObjC2, the category name is optional (not an error). if (Tok.is(tok::identifier)) { @@ -147,19 +146,21 @@ Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration( return 0; } rparenLoc = ConsumeParen(); - SourceLocation endProtoLoc; + // Next, we need to check for any protocol references. - if (Tok.is(tok::less)) { - if (ParseObjCProtocolReferences(ProtocolRefs, endProtoLoc)) - return 0; - } + SourceLocation EndProtoLoc; + llvm::SmallVector<DeclTy *, 8> ProtocolRefs; + if (Tok.is(tok::less) && + ParseObjCProtocolReferences(ProtocolRefs, true, EndProtoLoc)) + return 0; + if (attrList) // categories don't support attributes. Diag(Tok, diag::err_objc_no_attributes_on_category); DeclTy *CategoryType = Actions.ActOnStartCategoryInterface(atLoc, nameId, nameLoc, categoryId, categoryLoc, &ProtocolRefs[0], ProtocolRefs.size(), - endProtoLoc); + EndProtoLoc); ParseObjCInterfaceDeclList(CategoryType, tok::objc_not_keyword); diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 7772006510..9584dcc468 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -624,13 +624,14 @@ public: DeclTy * const *ProtoRefNames, unsigned NumProtoRefs, SourceLocation EndProtoLoc); - virtual DeclTy *ActOnStartCategoryInterface( - SourceLocation AtInterfaceLoc, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *CategoryName, SourceLocation CategoryLoc, - const IdentifierLocPair *ProtoRefNames, - unsigned NumProtoRefs, - SourceLocation EndProtoLoc); + virtual DeclTy *ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, + IdentifierInfo *ClassName, + SourceLocation ClassLoc, + IdentifierInfo *CategoryName, + SourceLocation CategoryLoc, + DeclTy * const *ProtoRefs, + unsigned NumProtoRefs, + SourceLocation EndProtoLoc); virtual DeclTy *ActOnStartClassImplementation( SourceLocation AtClassImplLoc, diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 5bafa236fb..570437d071 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -402,7 +402,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *CategoryName, SourceLocation CategoryLoc, - const IdentifierLocPair *ProtoRefNames, + DeclTy * const *ProtoRefs, unsigned NumProtoRefs, SourceLocation EndProtoLoc) { ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName); @@ -430,24 +430,9 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, } if (NumProtoRefs) { - 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].first]; - if (!RefPDecl) - Diag(ProtoRefNames[i].second, diag::err_undeclared_protocol, - ProtoRefNames[i].first->getName()); - else { - if (RefPDecl->isForwardDecl()) - Diag(ProtoRefNames[i].second, diag::warn_undef_protocolref, - ProtoRefNames[i].first->getName()); - RefProtocols.push_back(RefPDecl); - } - } - if (!RefProtocols.empty()) - CDecl->addReferencedProtocols(&RefProtocols[0], RefProtocols.size()); + CDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs); + CDecl->setLocEnd(EndProtoLoc); } - CDecl->setLocEnd(EndProtoLoc); return CDecl; } |