Encode Class, SEL and Objective-C objects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43540 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/Sema.cpp b/Sema/Sema.cpp
index 2be198d..92d17e1 100644
--- a/Sema/Sema.cpp
+++ b/Sema/Sema.cpp
@@ -82,6 +82,25 @@
return Context.getObjcProtoType();
}
+/// GetObjcClassType - See comments for Sema::GetObjcIdType above; replace "id"
+/// with "Protocol".
+QualType Sema::GetObjcClassType(SourceLocation Loc) {
+ assert(TUScope && "GetObjcClassType(): Top-level scope is null");
+ if (!Context.getObjcClassType().isNull())
+ return Context.getObjcClassType();
+
+ IdentifierInfo *ClassIdent = &Context.Idents.get("Class");
+ ScopedDecl *ClassDecl = LookupScopedDecl(ClassIdent, Decl::IDNS_Ordinary,
+ SourceLocation(), TUScope);
+ TypedefDecl *ObjcClassTypedef = dyn_cast_or_null<TypedefDecl>(ClassDecl);
+ if (!ObjcClassTypedef) {
+ Diag(Loc, diag::err_missing_class_definition);
+ return QualType();
+ }
+ Context.setObjcClassType(ObjcClassTypedef);
+ return Context.getObjcClassType();
+}
+
Sema::Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup)
: PP(pp), Context(ctxt), CurFunctionDecl(0), LastInGroupList(prevInGroup) {