diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-20 05:54:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-20 05:54:35 +0000 |
commit | 55c8d39695ef640174768a030bbded3da0655ea8 (patch) | |
tree | 1d47c653624be398deca02a4d56e4b11e50a160c | |
parent | 617bc3d02e104d80abdfa0b499f8257bc2142923 (diff) | |
download | bcm5719-llvm-55c8d39695ef640174768a030bbded3da0655ea8.tar.gz bcm5719-llvm-55c8d39695ef640174768a030bbded3da0655ea8.zip |
move some objc decl destruction out of dtors into Destroy method.
llvm-svn: 65111
-rw-r--r-- | clang/include/clang/AST/DeclObjC.h | 11 | ||||
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 15 |
2 files changed, 18 insertions, 8 deletions
diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index 88cf2276c71..309b33ff99b 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -151,7 +151,9 @@ private: ParamInfo(0), NumMethodParams(0), EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {} - virtual ~ObjCMethodDecl(); + virtual ~ObjCMethodDecl() { + assert(ParamInfo == 0 && "Destroy not called?"); + } public: @@ -595,12 +597,17 @@ class ObjCProtocolDecl : public ObjCContainerDecl { isForwardProtoDecl(true) { } - virtual ~ObjCProtocolDecl(); + virtual ~ObjCProtocolDecl() { + assert(PropertyDecl == 0 && "Destroy not called?"); + } public: static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id); + /// Destroy - Call destructors and release memory. + virtual void Destroy(ASTContext& C); + const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const { return ReferencedProtocols; } diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 506d3e4c387..95ba2e0c583 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -35,17 +35,16 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C, isVariadic, isSynthesized, impControl); } -ObjCMethodDecl::~ObjCMethodDecl() { - delete [] ParamInfo; -} - void ObjCMethodDecl::Destroy(ASTContext& C) { if (Body) Body->Destroy(C); if (SelfDecl) SelfDecl->Destroy(C); for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I) if (*I) (*I)->Destroy(C); - + + delete [] ParamInfo; + ParamInfo = 0; + Decl::Destroy(C); } @@ -102,11 +101,15 @@ ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC, return new (C) ObjCProtocolDecl(DC, L, Id); } -ObjCProtocolDecl::~ObjCProtocolDecl() { +void ObjCProtocolDecl::Destroy(ASTContext &C) { delete [] PropertyDecl; + PropertyDecl = 0; + ObjCContainerDecl::Destroy(C); } + + ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, ObjCInterfaceDecl **Elts, unsigned nElts) { |