diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-01 19:29:29 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-01 19:29:29 +0000 |
commit | e6e48b1490fe79ca8d44718e48f8644a28efa097 (patch) | |
tree | 5a6249e5bdcfbd786cbf68de755aca1c133a7e92 /clang/lib/AST | |
parent | 01fb1135d66125f02111f04273684d25d73d2645 (diff) | |
download | bcm5719-llvm-e6e48b1490fe79ca8d44718e48f8644a28efa097.tar.gz bcm5719-llvm-e6e48b1490fe79ca8d44718e48f8644a28efa097.zip |
Move the data that corresponds to the definition of a protocol into a
separately-allocated DefinitionData structure. Introduce various
functions that will help with the separation of declarations from
definitions (isThisDeclarationADefinition(), hasDefinition(),
getDefinition()).
llvm-svn: 147408
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 7 | ||||
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 12 | ||||
-rw-r--r-- | clang/lib/AST/DumpXML.cpp | 1 |
3 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 67045059cfd..fe7049492f8 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -3119,7 +3119,7 @@ Decl *ASTNodeImporter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) { } ObjCProtocolDecl *ToProto = MergeWithProtocol; - if (!ToProto || ToProto->isForwardDecl()) { + if (!ToProto || !ToProto->hasDefinition()) { if (!ToProto) { ToProto = ObjCProtocolDecl::Create(Importer.getToContext(), DC, Name.getAsIdentifierInfo(), Loc, @@ -3127,9 +3127,12 @@ Decl *ASTNodeImporter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) { D->isInitiallyForwardDecl()); ToProto->setLexicalDeclContext(LexicalDC); LexicalDC->addDeclInternal(ToProto); - if (D->isInitiallyForwardDecl() && !D->isForwardDecl()) + if (D->isInitiallyForwardDecl() && D->hasDefinition()) ToProto->completedForwardDecl(); } + if (!ToProto->hasDefinition()) + ToProto->startDefinition(); + Importer.Imported(D, ToProto); // Import protocols diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 75100ecb3cb..f5828fcb4ce 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -1003,9 +1003,19 @@ ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel, return NULL; } +void ObjCProtocolDecl::allocateDefinitionData() { + assert(!Data && "Protocol already has a definition!"); + Data = new (getASTContext()) DefinitionData; +} + +void ObjCProtocolDecl::startDefinition() { + allocateDefinitionData(); +} + void ObjCProtocolDecl::completedForwardDecl() { - assert(isForwardDecl() && "Only valid to call for forward refs"); + assert(!hasDefinition() && "Only valid to call for forward refs"); isForwardProtoDecl = false; + startDefinition(); if (ASTMutationListener *L = getASTContext().getASTMutationListener()) L->CompletedObjCForwardRef(this); } diff --git a/clang/lib/AST/DumpXML.cpp b/clang/lib/AST/DumpXML.cpp index 959bbcbb174..561fb8f372d 100644 --- a/clang/lib/AST/DumpXML.cpp +++ b/clang/lib/AST/DumpXML.cpp @@ -819,7 +819,6 @@ struct XMLDumper : public XMLDeclVisitor<XMLDumper>, // ObjCProtocolDecl void visitObjCProtocolDeclAttrs(ObjCProtocolDecl *D) { - setFlag("forward_decl", D->isForwardDecl()); } void visitObjCProtocolDeclChildren(ObjCProtocolDecl *D) { if (D->protocol_begin() != D->protocol_end()) { |