From c25d7a7fe03d28163e4150d404fe34875e4283f2 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 9 Jan 2009 00:49:46 +0000 Subject: Addressed the issue in , where we failed to rewrite @class declarations that showed up within linkage specifications because those @class declarations never made it any place where the rewriter could find them. Moved all of the ObjC*Decl nodes over to ScopedDecls, so that they can live in the appropriate top-level or transparent DeclContext near the top level, e.g., TranslationUnitDecl or LinkageSpecDecl. Objective-C declarations now show up in a traversal of the declarations in a DeclContext (they didn't before!). This way, the rewriter finds all Objective-C declarations within linkage specifications. llvm-svn: 61966 --- clang/lib/AST/DeclObjC.cpp | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'clang/lib/AST/DeclObjC.cpp') diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index b7c0cf79b94..194544f9fa8 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -51,12 +51,13 @@ void ObjCMethodDecl::Destroy(ASTContext& C) { } ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C, + DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, SourceLocation ClassLoc, bool ForwardDecl, bool isInternal){ void *Mem = C.getAllocator().Allocate(); - return new (Mem) ObjCInterfaceDecl(atLoc, Id, ClassLoc, ForwardDecl, + return new (Mem) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, ForwardDecl, isInternal); } @@ -104,11 +105,11 @@ void ObjCAtDefsFieldDecl::Destroy(ASTContext& C) { C.getAllocator().Deallocate((void *)this); } -ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, +ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id) { void *Mem = C.getAllocator().Allocate(); - return new (Mem) ObjCProtocolDecl(L, Id); + return new (Mem) ObjCProtocolDecl(DC, L, Id); } ObjCProtocolDecl::~ObjCProtocolDecl() { @@ -130,11 +131,11 @@ void ObjCProtocolDecl::Destroy(ASTContext& C) { } -ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, +ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, ObjCInterfaceDecl **Elts, unsigned nElts) { void *Mem = C.getAllocator().Allocate(); - return new (Mem) ObjCClassDecl(L, Elts, nElts); + return new (Mem) ObjCClassDecl(DC, L, Elts, nElts); } ObjCClassDecl::~ObjCClassDecl() { @@ -155,58 +156,58 @@ void ObjCClassDecl::Destroy(ASTContext& C) { } ObjCForwardProtocolDecl * -ObjCForwardProtocolDecl::Create(ASTContext &C, +ObjCForwardProtocolDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, ObjCProtocolDecl **Elts, unsigned NumElts) { void *Mem = C.getAllocator().Allocate(); - return new (Mem) ObjCForwardProtocolDecl(L, Elts, NumElts); + return new (Mem) ObjCForwardProtocolDecl(DC, L, Elts, NumElts); } ObjCForwardProtocolDecl::~ObjCForwardProtocolDecl() { delete [] ReferencedProtocols; } -ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, +ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id) { void *Mem = C.getAllocator().Allocate(); - return new (Mem) ObjCCategoryDecl(L, Id); + return new (Mem) ObjCCategoryDecl(DC, L, Id); } ObjCCategoryImplDecl * -ObjCCategoryImplDecl::Create(ASTContext &C, +ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,IdentifierInfo *Id, ObjCInterfaceDecl *ClassInterface) { void *Mem = C.getAllocator().Allocate(); - return new (Mem) ObjCCategoryImplDecl(L, Id, ClassInterface); + return new (Mem) ObjCCategoryImplDecl(DC, L, Id, ClassInterface); } ObjCImplementationDecl * -ObjCImplementationDecl::Create(ASTContext &C, +ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *ClassInterface, ObjCInterfaceDecl *SuperDecl) { void *Mem = C.getAllocator().Allocate(); - return new (Mem) ObjCImplementationDecl(L, Id, ClassInterface, SuperDecl); + return new (Mem) ObjCImplementationDecl(DC, L, Id, ClassInterface, SuperDecl); } ObjCCompatibleAliasDecl * -ObjCCompatibleAliasDecl::Create(ASTContext &C, +ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl* AliasedClass) { void *Mem = C.getAllocator().Allocate(); - return new (Mem) ObjCCompatibleAliasDecl(L, Id, AliasedClass); + return new (Mem) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass); } -ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, +ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, PropertyControl propControl) { void *Mem = C.getAllocator().Allocate(); - return new (Mem) ObjCPropertyDecl(L, Id, T); + return new (Mem) ObjCPropertyDecl(DC, L, Id, T); } //===----------------------------------------------------------------------===// @@ -757,13 +758,14 @@ ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() { } ObjCPropertyImplDecl *ObjCPropertyImplDecl::Create(ASTContext &C, + DeclContext *DC, SourceLocation atLoc, SourceLocation L, ObjCPropertyDecl *property, Kind PK, ObjCIvarDecl *ivar) { void *Mem = C.getAllocator().Allocate(); - return new (Mem) ObjCPropertyImplDecl(atLoc, L, property, PK, ivar); + return new (Mem) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar); } -- cgit v1.2.3