diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2007-12-07 00:18:54 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2007-12-07 00:18:54 +0000 |
| commit | 2bbd03a7551146404d0db339882db113b6718721 (patch) | |
| tree | b9f74c9ce521e2f0233cbb28ccab6c9cd6d56325 /clang/Sema/Sema.cpp | |
| parent | c829e5cdf07db4335fb16657baea89b4803b1942 (diff) | |
| download | bcm5719-llvm-2bbd03a7551146404d0db339882db113b6718721.tar.gz bcm5719-llvm-2bbd03a7551146404d0db339882db113b6718721.zip | |
Patch to implement "Protocol" as a built-in type declared as
"@class Protocol;"
llvm-svn: 44670
Diffstat (limited to 'clang/Sema/Sema.cpp')
| -rw-r--r-- | clang/Sema/Sema.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/clang/Sema/Sema.cpp b/clang/Sema/Sema.cpp index 7bafd7db883..7a657cd5e15 100644 --- a/clang/Sema/Sema.cpp +++ b/clang/Sema/Sema.cpp @@ -23,7 +23,7 @@ using namespace clang; bool Sema::isBuiltinObjcType(TypedefDecl *TD) { const char *typeName = TD->getIdentifier()->getName(); return strcmp(typeName, "id") == 0 || strcmp(typeName, "Class") == 0 || - strcmp(typeName, "SEL") == 0; + strcmp(typeName, "SEL") == 0 || strcmp(typeName, "Protocol") == 0; } void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { @@ -38,31 +38,16 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) { t = dyn_cast<TypedefType>(Context.getObjcClassType().getTypePtr()); t->getDecl()->getIdentifier()->setFETokenInfo(t->getDecl()); TUScope->AddDecl(t->getDecl()); + ObjcInterfaceType *it = dyn_cast<ObjcInterfaceType>(Context.getObjcProtoType()); + ObjcInterfaceDecl *IDecl = it->getDecl(); + IDecl->getIdentifier()->setFETokenInfo(IDecl); + TUScope->AddDecl(IDecl); t = dyn_cast<TypedefType>(Context.getObjcSelType().getTypePtr()); t->getDecl()->getIdentifier()->setFETokenInfo(t->getDecl()); TUScope->AddDecl(t->getDecl()); } } -/// FIXME: remove this. -/// 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) : PP(pp), Context(ctxt), CurFunctionDecl(0), CurMethodDecl(0) { @@ -91,6 +76,11 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt) ClassT, 0); Context.setObjcClassType(ClassTypedef); + // Synthesize "@class Protocol; + ObjcInterfaceDecl *ProtocolDecl = new ObjcInterfaceDecl(SourceLocation(), 0, + &Context.Idents.get("Protocol"), true); + Context.setObjcProtoType(Context.getObjcInterfaceType(ProtocolDecl)); + // Synthesize "typedef struct objc_object { Class isa; } *id;" RecordDecl *ObjectTag = new RecordDecl(Decl::Struct, SourceLocation(), &IT.get("objc_object"), 0); @@ -111,6 +101,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt) &Context.Idents.get("SEL"), SelT, 0); Context.setObjcSelType(SelTypedef); + } TUScope = 0; } |

