summaryrefslogtreecommitdiffstats
path: root/lib/AST/DeclObjC.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/AST/DeclObjC.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/AST/DeclObjC.cpp')
-rw-r--r--lib/AST/DeclObjC.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index f5828fcb4c..341f0f5e93 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -1005,11 +1005,17 @@ ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel,
void ObjCProtocolDecl::allocateDefinitionData() {
assert(!Data && "Protocol already has a definition!");
- Data = new (getASTContext()) DefinitionData;
+ Data = new (getASTContext()) DefinitionData;
+ Data->Definition = this;
}
void ObjCProtocolDecl::startDefinition() {
allocateDefinitionData();
+
+ // Update all of the declarations with a pointer to the definition.
+ for (redecl_iterator RD = redecls_begin(), RDEnd = redecls_end();
+ RD != RDEnd; ++RD)
+ RD->Data = this->Data;
}
void ObjCProtocolDecl::completedForwardDecl() {