]> granicus.if.org Git - clang/commitdiff
Added Stmt::DestroyChildren, which will be used by the dstors of the subclasses of...
authorTed Kremenek <kremenek@apple.com>
Mon, 19 May 2008 22:02:12 +0000 (22:02 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 19 May 2008 22:02:12 +0000 (22:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51278 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 5875d008b37d85c047d8f27302c42f9640ad773d..dac69a16103373bcb8dfc30398676d7575780964 100644 (file)
@@ -50,6 +50,12 @@ public:
 };
 private:
   const StmtClass sClass;
+  
+protected:
+  /// DestroyChildren - Invoked by destructors of subclasses of Stmt to
+  ///  recursively release child AST nodes.
+  void DestroyChildren();
+  
 public:
   Stmt(StmtClass SC) : sClass(SC) { 
     if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
index 572280bc05456aadae6d4c471d78410e744bef06..ffc6c2e62a8567c5b0bfd9929bdfd8c8ece09a53 100644 (file)
@@ -42,6 +42,11 @@ const char *Stmt::getStmtClassName() const {
   return getStmtInfoTableEntry(sClass).Name;
 }
 
+void Stmt::DestroyChildren() {
+  for (child_iterator I = child_begin(), E = child_end(); I !=E; ++I)
+    delete *I; // Handles the case when *I == NULL.
+}
+
 void Stmt::PrintStats() {
   // Ensure the table is primed.
   getStmtInfoTableEntry(Stmt::NullStmtClass);