Implementation of AST for @protocol expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43075 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/Sema.cpp b/Sema/Sema.cpp
index dc68eb0..5bd5df5 100644
--- a/Sema/Sema.cpp
+++ b/Sema/Sema.cpp
@@ -63,6 +63,24 @@
return Context.getObjcSelType();
}
+/// GetObjcProtoType - See comments for Sema::GetObjcIdType above; replace "id"
+/// with "Protocol".
+QualType Sema::GetObjcProtoType(SourceLocation Loc) {
+ assert(TUScope && "GetObjcProtoType(): Top-level scope is null");
+ if (Context.getObjcProtoType().isNull()) {
+ IdentifierInfo *ProtoIdent = &Context.Idents.get("Protocol");
+ ScopedDecl *ProtoDecl = LookupScopedDecl(ProtoIdent, Decl::IDNS_Ordinary,
+ SourceLocation(), TUScope);
+ TypedefDecl *ObjcProtoTypedef = dyn_cast_or_null<TypedefDecl>(ProtoDecl);
+ if (!ObjcProtoTypedef) {
+ Diag(Loc, diag::err_missing_proto_definition);
+ return QualType();
+ }
+ Context.setObjcProtoType(ObjcProtoTypedef);
+ }
+ return Context.getObjcProtoType();
+}
+
Sema::Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup)
: PP(pp), Context(ctxt), CurFunctionDecl(0), LastInGroupList(prevInGroup) {