[cfe-commits] r51278 - in /cfe/trunk: include/clang/AST/Stmt.h lib/AST/Stmt.cpp

Ted Kremenek kremenek at apple.com
Mon May 19 15:02:12 PDT 2008


Author: kremenek
Date: Mon May 19 17:02:12 2008
New Revision: 51278

URL: http://llvm.org/viewvc/llvm-project?rev=51278&view=rev
Log:
Added Stmt::DestroyChildren, which will be used by the dstors of the subclasses of Stmt to recursively delete their child AST nodes.

Modified:
    cfe/trunk/include/clang/AST/Stmt.h
    cfe/trunk/lib/AST/Stmt.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=51278&r1=51277&r2=51278&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Mon May 19 17:02:12 2008
@@ -50,6 +50,12 @@
 };
 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);

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=51278&r1=51277&r2=51278&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Mon May 19 17:02:12 2008
@@ -42,6 +42,11 @@
   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);





More information about the cfe-commits mailing list