diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-01 21:23:57 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-01 21:23:57 +0000 |
commit | bd9482d859a74bf2c45ef8b8aedec61c0e1c8374 (patch) | |
tree | 827657aa0ed457521e505ae199c93c9166b7181f /lib/AST | |
parent | a6387f3b447015073192f1e1cafec3ebd0294c8c (diff) |
Eliminate ObjCForwardProtocolDecl, which is redundant now that
ObjCProtocolDecl modules forward declarations properly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147415 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/ASTImporter.cpp | 45 | ||||
-rw-r--r-- | lib/AST/Decl.cpp | 1 | ||||
-rw-r--r-- | lib/AST/DeclBase.cpp | 1 | ||||
-rw-r--r-- | lib/AST/DeclObjC.cpp | 24 | ||||
-rw-r--r-- | lib/AST/DeclPrinter.cpp | 16 | ||||
-rw-r--r-- | lib/AST/DumpXML.cpp | 13 |
6 files changed, 11 insertions, 89 deletions
diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 9931961c05..6ee8ba3a5f 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -127,7 +127,6 @@ namespace clang { Decl *VisitObjCImplementationDecl(ObjCImplementationDecl *D); Decl *VisitObjCPropertyDecl(ObjCPropertyDecl *D); Decl *VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); - Decl *VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D); Decl *VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); Decl *VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); Decl *VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); @@ -3562,50 +3561,6 @@ Decl *ASTNodeImporter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { return ToImpl; } -Decl * -ASTNodeImporter::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) { - // Import the context of this declaration. - DeclContext *DC = Importer.ImportContext(D->getDeclContext()); - if (!DC) - return 0; - - DeclContext *LexicalDC = DC; - if (D->getDeclContext() != D->getLexicalDeclContext()) { - LexicalDC = Importer.ImportContext(D->getLexicalDeclContext()); - if (!LexicalDC) - return 0; - } - - // Import the location of this declaration. - SourceLocation Loc = Importer.Import(D->getLocation()); - - SmallVector<ObjCProtocolDecl *, 4> Protocols; - SmallVector<SourceLocation, 4> Locations; - ObjCForwardProtocolDecl::protocol_loc_iterator FromProtoLoc - = D->protocol_loc_begin(); - for (ObjCForwardProtocolDecl::protocol_iterator FromProto - = D->protocol_begin(), FromProtoEnd = D->protocol_end(); - FromProto != FromProtoEnd; - ++FromProto, ++FromProtoLoc) { - ObjCProtocolDecl *ToProto - = cast_or_null<ObjCProtocolDecl>(Importer.Import(*FromProto)); - if (!ToProto) - continue; - - Protocols.push_back(ToProto); - Locations.push_back(Importer.Import(*FromProtoLoc)); - } - - ObjCForwardProtocolDecl *ToForward - = ObjCForwardProtocolDecl::Create(Importer.getToContext(), DC, Loc, - Protocols.data(), Protocols.size(), - Locations.data()); - ToForward->setLexicalDeclContext(LexicalDC); - LexicalDC->addDeclInternal(ToForward); - Importer.Imported(D, ToForward); - return ToForward; -} - Decl *ASTNodeImporter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { // For template arguments, we adopt the translation unit as our declaration // context. This context will be fixed when the actual template declaration diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index b4a4eb1d13..847e906af7 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -733,7 +733,6 @@ static LinkageInfo getLVForDecl(const NamedDecl *D, LVFlags Flags) { case Decl::ObjCCategory: case Decl::ObjCCategoryImpl: case Decl::ObjCCompatibleAlias: - case Decl::ObjCForwardProtocol: case Decl::ObjCImplementation: case Decl::ObjCMethod: case Decl::ObjCProperty: diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index a71275a2c1..d60edd06e9 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -496,7 +496,6 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) { case FileScopeAsm: case StaticAssert: case ObjCPropertyImpl: - case ObjCForwardProtocol: case Block: case TranslationUnit: diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 27da21a18f..aabea0434c 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -1042,30 +1042,6 @@ void ObjCProtocolDecl::startDefinition() { } //===----------------------------------------------------------------------===// -// ObjCForwardProtocolDecl -//===----------------------------------------------------------------------===// - -void ObjCForwardProtocolDecl::anchor() { } - -ObjCForwardProtocolDecl:: -ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L, - ObjCProtocolDecl *const *Elts, unsigned nElts, - const SourceLocation *Locs, ASTContext &C) -: Decl(ObjCForwardProtocol, DC, L) { - ReferencedProtocols.set(Elts, nElts, Locs, C); -} - - -ObjCForwardProtocolDecl * -ObjCForwardProtocolDecl::Create(ASTContext &C, DeclContext *DC, - SourceLocation L, - ObjCProtocolDecl *const *Elts, - unsigned NumElts, - const SourceLocation *Locs) { - return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts, Locs, C); -} - -//===----------------------------------------------------------------------===// // ObjCCategoryDecl //===----------------------------------------------------------------------===// diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 9b72bb416a..73dac3b73e 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -72,7 +72,6 @@ namespace { void VisitObjCMethodDecl(ObjCMethodDecl *D); void VisitObjCImplementationDecl(ObjCImplementationDecl *D); void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); - void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D); void VisitObjCProtocolDecl(ObjCProtocolDecl *D); void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); void VisitObjCCategoryDecl(ObjCCategoryDecl *D); @@ -932,17 +931,12 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) { // FIXME: implement the rest... } -void DeclPrinter::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) { - Out << "@protocol "; - for (ObjCForwardProtocolDecl::protocol_iterator I = D->protocol_begin(), - E = D->protocol_end(); - I != E; ++I) { - if (I != D->protocol_begin()) Out << ", "; - Out << **I; - } -} - void DeclPrinter::VisitObjCProtocolDecl(ObjCProtocolDecl *PID) { + if (!PID->isThisDeclarationADefinition()) { + Out << "@protocol " << PID->getIdentifier() << ";\n"; + return; + } + Out << "@protocol " << *PID << '\n'; VisitDeclContext(PID, false); Out << "@end"; diff --git a/lib/AST/DumpXML.cpp b/lib/AST/DumpXML.cpp index 561fb8f372..4ef4ce5e38 100644 --- a/lib/AST/DumpXML.cpp +++ b/lib/AST/DumpXML.cpp @@ -810,17 +810,13 @@ struct XMLDumper : public XMLDeclVisitor<XMLDumper>, } } - // ObjCForwardProtocolDecl - void visitObjCForwardProtocolDeclChildren(ObjCForwardProtocolDecl *D) { - for (ObjCForwardProtocolDecl::protocol_iterator - I = D->protocol_begin(), E = D->protocol_end(); I != E; ++I) - visitDeclRef(*I); - } - // ObjCProtocolDecl void visitObjCProtocolDeclAttrs(ObjCProtocolDecl *D) { } void visitObjCProtocolDeclChildren(ObjCProtocolDecl *D) { + if (!D->isThisDeclarationADefinition()) + return; + if (D->protocol_begin() != D->protocol_end()) { TemporaryContainer C(*this, "protocols"); for (ObjCInterfaceDecl::protocol_iterator @@ -829,6 +825,9 @@ struct XMLDumper : public XMLDeclVisitor<XMLDumper>, } } void visitObjCProtocolDeclAsContext(ObjCProtocolDecl *D) { + if (!D->isThisDeclarationADefinition()) + return; + visitDeclContext(D); } |