diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-12-16 03:12:41 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-12-16 03:12:41 +0000 |
commit | 0af550115df1f57f17a4f125ff0e8b34820c65d1 (patch) | |
tree | ef5aba0397d507447128ebb837e6c77b782dfb62 /lib/AST/DeclObjC.cpp | |
parent | bd79119a50172db92ad3ce77ec3ac3c51e42a126 (diff) |
Fix chaining of ObjCInterfaceDecl redeclarations
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r-- | lib/AST/DeclObjC.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index d420b2be49..317dc95f54 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -225,18 +225,19 @@ void ObjCInterfaceDecl::mergeClassExtensionProtocolList( void ObjCInterfaceDecl::allocateDefinitionData() { assert(!hasDefinition() && "ObjC class already has a definition"); Data = new (getASTContext()) DefinitionData(); - Data->Definition = this; - + Data->Definition = this; +} + +void ObjCInterfaceDecl::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) { if (*RD != this) RD->Data = Data; } -} -void ObjCInterfaceDecl::startDefinition() { - allocateDefinitionData(); if (ASTMutationListener *L = getASTContext().getASTMutationListener()) L->CompletedObjCForwardRef(this); } @@ -674,9 +675,24 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, + ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc, bool isInternal){ - return new (C) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, isInternal); + ObjCInterfaceDecl *Result = new (C) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, + isInternal); + C.getObjCInterfaceType(Result, PrevDecl); + + if (PrevDecl) { + Result->Data = PrevDecl->Data; + Result->setPreviousDeclaration(PrevDecl); + } + + return Result; +} + +ObjCInterfaceDecl *ObjCInterfaceDecl::CreateEmpty(ASTContext &C) { + return new (C) ObjCInterfaceDecl(0, SourceLocation(), 0, SourceLocation(), + false); } ObjCInterfaceDecl:: @@ -851,14 +867,6 @@ bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto, return false; } -void ObjCInterfaceDecl::setPreviousDeclaration(ObjCInterfaceDecl *PrevDecl) { - redeclarable_base::setPreviousDeclaration(PrevDecl); - - // Inherit the 'Data' pointer from the previous declaration. - if (PrevDecl) - Data = PrevDecl->Data; -} - //===----------------------------------------------------------------------===// // ObjCIvarDecl //===----------------------------------------------------------------------===// |