From: Chris Lattner Date: Fri, 20 Feb 2009 21:02:11 +0000 (+0000) Subject: rename ObjCList::clear() -> ObjCList::Destroy(). Require that destroy is called X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88cf7a16902a9189d16653e1061cfda333187b58;p=clang rename ObjCList::clear() -> ObjCList::Destroy(). Require that destroy is called before the dtor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65156 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 4f51f66bb3..4d9b7f7a19 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -48,12 +48,13 @@ class ObjCList { public: ObjCList() : List(0), NumElts(0) {} ~ObjCList() { - delete[] List; + assert(List == 0 && "Destroy should have been called before dtor"); } - void clear() { + void Destroy() { delete[] List; NumElts = 0; + List = 0; } void set(T* const* InList, unsigned Elts) { diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 9e030d771a..ec67f5cf40 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -193,7 +193,7 @@ void ObjCMethodDecl::Destroy(ASTContext& C) { for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I) if (*I) (*I)->Destroy(C); - ParamInfo.clear(); + ParamInfo.Destroy(); Decl::Destroy(C); } @@ -280,7 +280,7 @@ void ObjCInterfaceDecl::Destroy(ASTContext &C) { for (ivar_iterator I=ivar_begin(), E=ivar_end(); I!=E; ++I) if (*I) (*I)->Destroy(C); - IVars.clear(); + IVars.Destroy(); // FIXME: CategoryList? // FIXME: Because there is no clear ownership @@ -357,7 +357,7 @@ ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC, } void ObjCProtocolDecl::Destroy(ASTContext &C) { - ReferencedProtocols.clear(); + ReferencedProtocols.Destroy(); ObjCContainerDecl::Destroy(C); } @@ -410,7 +410,7 @@ void ObjCClassDecl::Destroy(ASTContext &C) { // obviating this problem. Because of this situation, referenced // ObjCInterfaceDecls are destroyed in ~TranslationUnit. - ForwardDecls.clear(); + ForwardDecls.Destroy(); Decl::Destroy(C); } @@ -434,7 +434,7 @@ ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L, } void ObjCForwardProtocolDecl::Destroy(ASTContext &C) { - ReferencedProtocols.clear(); + ReferencedProtocols.Destroy(); Decl::Destroy(C); } @@ -524,7 +524,7 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC, /// Destroy - Call destructors and release memory. void ObjCImplementationDecl::Destroy(ASTContext& C) { - IVars.clear(); + IVars.Destroy(); Decl::Destroy(C); }