aboutsummaryrefslogtreecommitdiff
path: root/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST')
-rw-r--r--lib/AST/DeclBase.cpp6
-rw-r--r--lib/AST/DeclObjC.cpp8
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 983673fec8..a71275a2c1 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -784,8 +784,10 @@ DeclContext *DeclContext::getPrimaryContext() {
return this;
case Decl::ObjCProtocol:
- // FIXME: Update when protocols properly model forward declarations.
- // For now, it's fine to fall through
+ if (ObjCProtocolDecl *Def = cast<ObjCProtocolDecl>(this)->getDefinition())
+ return Def;
+
+ return this;
case Decl::ObjCCategory:
return this;
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() {