aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization/ASTReaderDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-01 19:51:50 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-01 19:51:50 +0000
commit1d784b277cdfd4eba03680715d2a082b3f28d295 (patch)
tree5070a82eb117524e15f1f15ef324c52f4ea61687 /lib/Serialization/ASTReaderDecl.cpp
parent5e2a1ff9f28d2eab256d2553e76a9c9d54693875 (diff)
Introduce the core infrastructure needed to model redeclaration chains
for Objective-C protocols, including: - Using the first declaration as the canonical declaration - Using the definition as the primary DeclContext - Making sure that all declarations have a pointer to the definition data, and that we know which declaration is the definition - Serialization support for redeclaration chains and for adding definitions to already-serialized declarations. However, note that we're not taking advantage of much of this code yet, because we're still re-using ObjCProtocolDecls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147410 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp
index f88a394e90..38b69413ac 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/lib/Serialization/ASTReaderDecl.cpp
@@ -760,6 +760,7 @@ void ASTDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) {
}
void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) {
+ VisitRedeclarable(PD);
VisitObjCContainerDecl(PD);
PD->InitiallyForwardDecl = Record[Idx++];
PD->isForwardProtoDecl = Record[Idx++];
@@ -782,8 +783,8 @@ void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) {
PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
Reader.getContext());
- // FIXME: Note that we have deserialized a definition.
- // Reader.PendingDefinitions.insert(PD);
+ // Note that we have deserialized a definition.
+ Reader.PendingDefinitions.insert(PD);
} else if (Def && Def->Data) {
PD->Data = Def->Data;
}
@@ -1712,6 +1713,8 @@ void ASTDeclReader::attachPreviousDecl(Decl *D, Decl *previous) {
TD->RedeclLink.setPointer(cast<TypedefNameDecl>(previous));
} else if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
ID->RedeclLink.setPointer(cast<ObjCInterfaceDecl>(previous));
+ } else if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D)) {
+ PD->RedeclLink.setPointer(cast<ObjCProtocolDecl>(previous));
} else {
RedeclarableTemplateDecl *TD = cast<RedeclarableTemplateDecl>(D);
TD->CommonOrPrev = cast<RedeclarableTemplateDecl>(previous);
@@ -1737,6 +1740,10 @@ void ASTDeclReader::attachLatestDecl(Decl *D, Decl *Latest) {
ID->RedeclLink
= Redeclarable<ObjCInterfaceDecl>::LatestDeclLink(
cast<ObjCInterfaceDecl>(Latest));
+ } else if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D)) {
+ PD->RedeclLink
+ = Redeclarable<ObjCProtocolDecl>::LatestDeclLink(
+ cast<ObjCProtocolDecl>(Latest));
} else {
RedeclarableTemplateDecl *TD = cast<RedeclarableTemplateDecl>(D);
TD->getCommonPtr()->Latest = cast<RedeclarableTemplateDecl>(Latest);
@@ -2201,6 +2208,8 @@ static Decl *getPreviousDecl(Decl *D) {
return TD->getPreviousDeclaration();
if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D))
return ID->getPreviousDeclaration();
+ if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D))
+ return PD->getPreviousDeclaration();
return cast<RedeclarableTemplateDecl>(D)->getPreviousDeclaration();
}
@@ -2217,6 +2226,8 @@ static Decl *getMostRecentDecl(Decl *D) {
return TD->getMostRecentDeclaration();
if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D))
return ID->getMostRecentDeclaration();
+ if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D))
+ return PD->getMostRecentDeclaration();
return cast<RedeclarableTemplateDecl>(D)->getMostRecentDeclaration();
}
@@ -2454,6 +2465,15 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
ID->Data = Def->Data;
break;
}
+
+ case UPD_OBJC_SET_PROTOCOL_DEFINITIONDATA: {
+ ObjCProtocolDecl *ID = cast<ObjCProtocolDecl>(D);
+ ObjCProtocolDecl *Def
+ = Reader.ReadDeclAs<ObjCProtocolDecl>(ModuleFile, Record, Idx);
+ if (Def->Data)
+ ID->Data = Def->Data;
+ break;
+ }
}
}
}