diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-01 19:51:50 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-01 19:51:50 +0000 |
commit | 1d784b277cdfd4eba03680715d2a082b3f28d295 (patch) | |
tree | 5070a82eb117524e15f1f15ef324c52f4ea61687 /lib/Serialization/ASTWriter.cpp | |
parent | 5e2a1ff9f28d2eab256d2553e76a9c9d54693875 (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/ASTWriter.cpp')
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index cfc83f7bc0..e59a3d39d1 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -3483,6 +3483,7 @@ void ASTWriter::ResolveDeclUpdatesBlocks() { case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: case UPD_OBJC_SET_CLASS_DEFINITIONDATA: + case UPD_OBJC_SET_PROTOCOL_DEFINITIONDATA: URec[Idx] = GetDeclRef(reinterpret_cast<Decl *>(URec[Idx])); ++Idx; break; @@ -4447,6 +4448,24 @@ void ASTWriter::CompletedObjCForwardRef(const ObjCContainerDecl *D) { } } } + + if (const ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D)) { + for (ObjCProtocolDecl::redecl_iterator I = PD->redecls_begin(), + E = PD->redecls_end(); + I != E; ++I) { + if (*I == PD) + continue; + + // We are interested when a PCH decl is modified. + if (I->isFromASTFile()) { + UpdateRecord &Record = DeclUpdates[*I]; + Record.push_back(UPD_OBJC_SET_PROTOCOL_DEFINITIONDATA); + assert((*I)->hasDefinition()); + assert((*I)->getDefinition() == D); + Record.push_back(reinterpret_cast<uint64_t>(D)); // the DefinitionDecl + } + } + } } void ASTWriter::AddedObjCPropertyInClassExtension(const ObjCPropertyDecl *Prop, |