Added Stmt::DestroyChildren, which will be used by the dstors of the subclasses of Stmt to recursively delete their child AST nodes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51278 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 572280b..ffc6c2e 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -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);