- Make sure default return/argument types (for methods) default to "id".
- Cache the "id" type in Sema...initialize ObjcIdType and TUScope (oops).
- Fix ActOnInstanceMessage to allow for "id" type receivers...still work to do (next).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42842 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/Sema.cpp b/Sema/Sema.cpp
index 125b0cb..f34aa63 100644
--- a/Sema/Sema.cpp
+++ b/Sema/Sema.cpp
@@ -23,6 +23,20 @@
TUScope = S;
}
+QualType Sema::GetObjcIdType() {
+ assert(TUScope && "GetObjcIdType(): Top-level scope is null");
+ if (ObjcIdType.isNull()) {
+ IdentifierInfo *IdIdent = &Context.Idents.get("id");
+ ScopedDecl *IdDecl = LookupScopedDecl(IdIdent, Decl::IDNS_Ordinary,
+ SourceLocation(), TUScope);
+ TypedefDecl *IdTypedef = dyn_cast_or_null<TypedefDecl>(IdDecl);
+ assert(IdTypedef && "GetObjcIdType(): Couldn't find 'id' type");
+ ObjcIdType = Context.getTypedefType(IdTypedef);
+ }
+ return ObjcIdType;
+}
+
+
Sema::Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup)
: PP(pp), Context(ctxt), CurFunctionDecl(0), LastInGroupList(prevInGroup) {
@@ -40,6 +54,9 @@
KnownFunctionIDs[ id_vfprintf ] = &IT.get("vfprintf");
KnownFunctionIDs[ id_vsprintf ] = &IT.get("vsprintf");
KnownFunctionIDs[ id_vprintf ] = &IT.get("vprintf");
+
+ TUScope = 0;
+ ObjcIdType = QualType();
}
void Sema::DeleteExpr(ExprTy *E) {