aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-05-19 22:02:12 +0000
committerTed Kremenek <kremenek@apple.com>2008-05-19 22:02:12 +0000
commit9c1863ef36a74e8203f00289d19856ad956f48b9 (patch)
treef26b536c116a91874e0002c10abddcbda2fd1ebf
parent4be1f47de20525ad90f02ba8682a7e2cbd3205d1 (diff)
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
-rw-r--r--include/clang/AST/Stmt.h6
-rw-r--r--lib/AST/Stmt.cpp5
2 files changed, 11 insertions, 0 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index 5875d008b3..dac69a1610 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -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);
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 572280bc05..ffc6c2e62a 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -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);