diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/ASTContext.cpp | 19 | ||||
-rw-r--r-- | lib/AST/DeclObjC.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/Sema.cpp | 18 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 10 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 3 |
5 files changed, 26 insertions, 26 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 9079dbe271..476d221fdf 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -224,7 +224,7 @@ ASTContext::ASTContext(LangOptions& LOpts, SourceManager &SM, SubstTemplateTemplateParmPacks(this_()), GlobalNestedNameSpecifier(0), Int128Decl(0), UInt128Decl(0), - ObjCIdDecl(0), ObjCSelDecl(0), ObjCClassDecl(0), + ObjCIdDecl(0), ObjCSelDecl(0), ObjCClassDecl(0), ObjCProtocolClassDecl(0), CFConstantStringTypeDecl(0), ObjCInstanceTypeDecl(0), FILEDecl(0), jmp_bufDecl(0), sigjmp_bufDecl(0), ucontext_tDecl(0), @@ -4906,10 +4906,6 @@ TypedefDecl *ASTContext::getObjCSelDecl() const { return ObjCSelDecl; } -void ASTContext::setObjCProtoType(QualType QT) { - ObjCProtoType = QT; -} - TypedefDecl *ASTContext::getObjCClassDecl() const { if (!ObjCClassDecl) { QualType T = getObjCObjectType(ObjCBuiltinClassTy, 0, 0); @@ -4924,6 +4920,19 @@ TypedefDecl *ASTContext::getObjCClassDecl() const { return ObjCClassDecl; } +ObjCInterfaceDecl *ASTContext::getObjCProtocolDecl() const { + if (!ObjCProtocolClassDecl) { + ObjCProtocolClassDecl + = ObjCInterfaceDecl::Create(*this, getTranslationUnitDecl(), + SourceLocation(), + &Idents.get("Protocol"), + /*PrevDecl=*/0, + SourceLocation(), true); + } + + return ObjCProtocolClassDecl; +} + void ASTContext::setObjCConstantStringInterface(ObjCInterfaceDecl *Decl) { assert(ObjCConstantStringType.isNull() && "'NSConstantString' type already set!"); diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 6a3bdfd4bb..2b97cf5686 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -682,7 +682,7 @@ ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() { // ObjCInterfaceDecl //===----------------------------------------------------------------------===// -ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C, +ObjCInterfaceDecl *ObjCInterfaceDecl::Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 447ce43dc5..0e4d22fc7f 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -77,19 +77,6 @@ void Sema::ActOnTranslationUnitScope(Scope *S) { PushDeclContext(S, Context.getTranslationUnitDecl()); VAListTagName = PP.getIdentifierInfo("__va_list_tag"); - - if (PP.getLangOptions().ObjC1) { - // Synthesize "@class Protocol; - if (Context.getObjCProtoType().isNull()) { - ObjCInterfaceDecl *ProtocolDecl = - ObjCInterfaceDecl::Create(Context, CurContext, SourceLocation(), - &Context.Idents.get("Protocol"), - /*PrevDecl=*/0, - SourceLocation(), true); - Context.setObjCProtoType(Context.getObjCInterfaceType(ProtocolDecl)); - PushOnScopeChains(ProtocolDecl, TUScope, false); - } - } } Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, @@ -174,6 +161,11 @@ void Sema::Initialize() { DeclarationName Class = &Context.Idents.get("Class"); if (IdResolver.begin(Class) == IdResolver.end()) PushOnScopeChains(Context.getObjCClassDecl(), TUScope); + + // Create the built-in forward declaratino for 'Protocol'. + DeclarationName Protocol = &Context.Idents.get("Protocol"); + if (IdResolver.begin(Protocol) == IdResolver.end()) + PushOnScopeChains(Context.getObjCProtocolDecl(), TUScope); } } diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index ab6a2512e3..57cd0212b3 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2813,17 +2813,12 @@ void ASTReader::InitializeContext() { // built-in types. Right now, we just ignore the problem. // Load the special types. - if (SpecialTypes.size() > NumSpecialTypeIDs) { + if (SpecialTypes.size() >= NumSpecialTypeIDs) { if (Context.getBuiltinVaListType().isNull()) { Context.setBuiltinVaListType( GetType(SpecialTypes[SPECIAL_TYPE_BUILTIN_VA_LIST])); } - if (unsigned Proto = SpecialTypes[SPECIAL_TYPE_OBJC_PROTOCOL]) { - if (Context.ObjCProtoType.isNull()) - Context.ObjCProtoType = GetType(Proto); - } - if (unsigned String = SpecialTypes[SPECIAL_TYPE_CF_CONSTANT_STRING]) { if (!Context.CFConstantStringTypeDecl) Context.setCFConstantStringType(GetType(String)); @@ -4584,6 +4579,9 @@ Decl *ASTReader::GetDecl(DeclID ID) { case PREDEF_DECL_OBJC_CLASS_ID: return Context.getObjCClassDecl(); + case PREDEF_DECL_OBJC_PROTOCOL_ID: + return Context.getObjCProtocolDecl(); + case PREDEF_DECL_INT_128_ID: return Context.getInt128Decl(); diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 20420d6ddc..7a09b32ac1 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -3134,6 +3134,8 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, DeclIDs[Context.ObjCSelDecl] = PREDEF_DECL_OBJC_SEL_ID; if (Context.ObjCClassDecl) DeclIDs[Context.ObjCClassDecl] = PREDEF_DECL_OBJC_CLASS_ID; + if (Context.ObjCProtocolClassDecl) + DeclIDs[Context.ObjCProtocolClassDecl] = PREDEF_DECL_OBJC_PROTOCOL_ID; if (Context.Int128Decl) DeclIDs[Context.Int128Decl] = PREDEF_DECL_INT_128_ID; if (Context.UInt128Decl) @@ -3313,7 +3315,6 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, // Form the record of special types. RecordData SpecialTypes; AddTypeRef(Context.getBuiltinVaListType(), SpecialTypes); - AddTypeRef(Context.ObjCProtoType, SpecialTypes); AddTypeRef(Context.getRawCFConstantStringType(), SpecialTypes); AddTypeRef(Context.getFILEType(), SpecialTypes); AddTypeRef(Context.getjmp_bufType(), SpecialTypes); |