diff options
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/DeclBase.cpp | 9 | ||||
-rw-r--r-- | lib/AST/DeclObjC.cpp | 10 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index b7941506b0..024f370c56 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -779,9 +779,16 @@ DeclContext *DeclContext::getPrimaryContext() { return this; case Decl::ObjCInterface: + if (ObjCInterfaceDecl *Def = cast<ObjCInterfaceDecl>(this)->getDefinition()) + return Def; + + return this; + case Decl::ObjCProtocol: + // FIXME: Update when protocols properly model forward declarations. + // For now, it's fine to fall through + case Decl::ObjCCategory: - // FIXME: Can Objective-C interfaces be forward-declared? return this; case Decl::ObjCImplementation: diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index decbd54c6d..1da0fab0ba 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -224,7 +224,15 @@ void ObjCInterfaceDecl::mergeClassExtensionProtocolList( void ObjCInterfaceDecl::allocateDefinitionData() { assert(!hasDefinition() && "ObjC class already has a definition"); - Definition = new (getASTContext()) DefinitionData(); + Definition.setPointer(new (getASTContext()) DefinitionData()); + Definition.setInt(true); + + // Update all of the declarations with a pointer to the definition. + for (redecl_iterator RD = redecls_begin(), RDEnd = redecls_end(); + RD != RDEnd; ++RD) { + if (*RD != this) + RD->Definition.setPointer(Definition.getPointer()); + } } void ObjCInterfaceDecl::startDefinition() { |