From: Douglas Gregor Date: Thu, 23 Apr 2009 03:59:07 +0000 (+0000) Subject: PCH (de-)serialization of the protocols in an ObjCInterfaceDecl X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=291be393aa33759e6e34b6429c5ffa206ba50115;p=clang PCH (de-)serialization of the protocols in an ObjCInterfaceDecl git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69860 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index c68741ad5c..816de41e43 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -416,7 +416,8 @@ public: typedef ObjCList::iterator protocol_iterator; protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } - + unsigned protocol_size() const { return ReferencedProtocols.size(); } + typedef ObjCList::iterator ivar_iterator; ivar_iterator ivar_begin() const { return IVars.begin(); } ivar_iterator ivar_end() const { return IVars.end(); } diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 72dda6cc6e..851eebc355 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -227,6 +227,11 @@ void PCHDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { ID->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr()); ID->setSuperClass(cast_or_null (Reader.GetDecl(Record[Idx++]))); + unsigned NumProtocols = Record[Idx++]; + llvm::SmallVector Protocols; + Protocols.reserve(NumProtocols); + for (unsigned I = 0; I != NumProtocols; ++I) + Protocols.push_back(cast(Reader.GetDecl(Record[Idx++]))); unsigned NumIvars = Record[Idx++]; llvm::SmallVector IVars; IVars.reserve(NumIvars); @@ -239,7 +244,7 @@ void PCHDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { ID->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); ID->setSuperClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); ID->setAtEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); - // FIXME: add protocols, categories. + // FIXME: add categories. } void PCHDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) { diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index ea2f359e50..dd8d95a56d 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -405,6 +405,11 @@ void PCHDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) { VisitObjCContainerDecl(D); Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record); Writer.AddDeclRef(D->getSuperClass(), Record); + Record.push_back(D->protocol_size()); + for (ObjCInterfaceDecl::protocol_iterator P = D->protocol_begin(), + PEnd = D->protocol_end(); + P != PEnd; ++P) + Writer.AddDeclRef(*P, Record); Record.push_back(D->ivar_size()); for (ObjCInterfaceDecl::ivar_iterator I = D->ivar_begin(), IEnd = D->ivar_end(); I != IEnd; ++I) @@ -414,7 +419,7 @@ void PCHDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) { Writer.AddSourceLocation(D->getClassLoc(), Record); Writer.AddSourceLocation(D->getSuperClassLoc(), Record); Writer.AddSourceLocation(D->getLocEnd(), Record); - // FIXME: add protocols, categories. + // FIXME: add categories. Code = pch::DECL_OBJC_INTERFACE; }