]> granicus.if.org Git - clang/commitdiff
PCH (de-)serialization of the protocols in an ObjCInterfaceDecl
authorDouglas Gregor <dgregor@apple.com>
Thu, 23 Apr 2009 03:59:07 +0000 (03:59 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 23 Apr 2009 03:59:07 +0000 (03:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69860 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/Frontend/PCHReader.cpp
lib/Frontend/PCHWriter.cpp

index c68741ad5cc0b8e7bc73fefad8e881f4befdef38..816de41e43367bebecbbd452b126cb1ccded596a 100644 (file)
@@ -416,7 +416,8 @@ public:
   typedef ObjCList<ObjCProtocolDecl>::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<ObjCIvarDecl>::iterator ivar_iterator;
   ivar_iterator ivar_begin() const { return IVars.begin(); }
   ivar_iterator ivar_end() const { return IVars.end(); }
index 72dda6cc6e9540e8bef6799592019b46bf514b73..851eebc35520ef91629b91632ba09aaa29dcb6c3 100644 (file)
@@ -227,6 +227,11 @@ void PCHDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
   ID->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr());
   ID->setSuperClass(cast_or_null<ObjCInterfaceDecl>
                        (Reader.GetDecl(Record[Idx++])));
+  unsigned NumProtocols = Record[Idx++];
+  llvm::SmallVector<ObjCProtocolDecl *, 16> Protocols;
+  Protocols.reserve(NumProtocols);
+  for (unsigned I = 0; I != NumProtocols; ++I)
+    Protocols.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
   unsigned NumIvars = Record[Idx++];
   llvm::SmallVector<ObjCIvarDecl *, 16> 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) {
index ea2f359e5036173d32eb2c75234f6030ccc5d194..dd8d95a56dfe1b961be5a4c4d3743d96c4ddfc9a 100644 (file)
@@ -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;
 }