]> granicus.if.org Git - clang/commitdiff
rename ObjCList::clear() -> ObjCList::Destroy(). Require that destroy is called
authorChris Lattner <sabre@nondot.org>
Fri, 20 Feb 2009 21:02:11 +0000 (21:02 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 20 Feb 2009 21:02:11 +0000 (21:02 +0000)
before the dtor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65156 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp

index 4f51f66bb3721eb6e36b3658af89fb253b63caed..4d9b7f7a191f45156273f48618b1512edff9c120 100644 (file)
@@ -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) {
index 9e030d771ada37aa55d975b2f074996a3fb4f23d..ec67f5cf40496957ae4fd4df815f3c49d2b48816 100644 (file)
@@ -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);
 }