aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclObjC.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-01 20:30:41 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-01 20:30:41 +0000
commit27c6da284f90e32cda0ec8f52a2b6ba5a2613252 (patch)
treea753b051d413b266667ca50e5929e7cbbddf2d03 /lib/AST/DeclObjC.cpp
parent1d784b277cdfd4eba03680715d2a082b3f28d295 (diff)
Wire up redeclaration chains for Objective-C protocols, so that both
forward declarations and definitions of an Objective-C protocol are represented within a single chain of ObjCProtocolDecls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r--lib/AST/DeclObjC.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 341f0f5e93..27da21a18f 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -967,12 +967,32 @@ ObjCAtDefsFieldDecl
void ObjCProtocolDecl::anchor() { }
+ObjCProtocolDecl::ObjCProtocolDecl(DeclContext *DC, IdentifierInfo *Id,
+ SourceLocation nameLoc,
+ SourceLocation atStartLoc,
+ ObjCProtocolDecl *PrevDecl,
+ bool isForwardDecl)
+ : ObjCContainerDecl(ObjCProtocol, DC, Id, nameLoc, atStartLoc),
+ Data(0),
+ InitiallyForwardDecl(isForwardDecl),
+ isForwardProtoDecl(isForwardDecl)
+{
+ setPreviousDeclaration(PrevDecl);
+ if (PrevDecl)
+ Data = PrevDecl->Data;
+}
+
ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC,
IdentifierInfo *Id,
SourceLocation nameLoc,
SourceLocation atStartLoc,
+ ObjCProtocolDecl *PrevDecl,
bool isForwardDecl) {
- return new (C) ObjCProtocolDecl(DC, Id, nameLoc, atStartLoc, isForwardDecl);
+ ObjCProtocolDecl *Result
+ = new (C) ObjCProtocolDecl(DC, Id, nameLoc, atStartLoc, PrevDecl,
+ isForwardDecl);
+
+ return Result;
}
ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) {
@@ -1016,12 +1036,7 @@ void ObjCProtocolDecl::startDefinition() {
for (redecl_iterator RD = redecls_begin(), RDEnd = redecls_end();
RD != RDEnd; ++RD)
RD->Data = this->Data;
-}
-
-void ObjCProtocolDecl::completedForwardDecl() {
- assert(!hasDefinition() && "Only valid to call for forward refs");
- isForwardProtoDecl = false;
- startDefinition();
+
if (ASTMutationListener *L = getASTContext().getASTMutationListener())
L->CompletedObjCForwardRef(this);
}