This is the first patch toward supporting protocol conforming
objective-c types. It also removes use of Scope* parameter in
getObjCProtocolDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42649 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index b827732..8f74378 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -104,8 +104,14 @@
IdentifierInfo *Id,
SourceLocation IdLoc) {
// Note that Protocols have their own namespace.
- ScopedDecl *PrDecl = LookupScopedDecl(Id, Decl::IDNS_Protocol,
- IdLoc, S);
+ ScopedDecl *PrDecl = NULL;
+ for (ScopedDecl *D = Id->getFETokenInfo<ScopedDecl>(); D; D = D->getNext()) {
+ if (D->getIdentifierNamespace() == Decl::IDNS_Protocol) {
+ PrDecl = D;
+ break;
+ }
+ }
+
if (PrDecl && !isa<ObjcProtocolDecl>(PrDecl))
PrDecl = 0;
return cast_or_null<ObjcProtocolDecl>(static_cast<Decl*>(PrDecl));
@@ -1007,6 +1013,24 @@
return PDecl;
}
+/// ActOnFindProtocolDeclaration - This routine looks for a previously
+/// declared protocol and returns it. If not found, issues diagnostic.
+/// Will build a list of previously protocol declarations found in the list.
+Action::DeclTy **
+Sema::ActOnFindProtocolDeclaration(Scope *S,
+ SourceLocation TypeLoc,
+ IdentifierInfo **ProtocolId,
+ unsigned NumProtocols) {
+ for (unsigned i = 0; i != NumProtocols; ++i) {
+ ObjcProtocolDecl *PDecl = getObjCProtocolDecl(S, ProtocolId[i],
+ TypeLoc);
+ if (!PDecl)
+ Diag(TypeLoc, diag::err_undeclared_protocol,
+ ProtocolId[i]->getName());
+ }
+ return 0;
+}
+
/// ActOnForwardProtocolDeclaration -
/// Scope will always be top level file scope.
Action::DeclTy *