aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-12-24 00:54:19 +0000
committerTed Kremenek <kremenek@apple.com>2009-12-24 00:54:19 +0000
commit7d02b8c3be58676a03046eef9d056063e55ada3e (patch)
treece89c8c61908a2631e25afb57fd7774bb09d83f1
parentcafefbe180bacd2c02c87ae1193f83fc6798cdfc (diff)
Modify WhileStmt::child_begin()/child_end() to include the initializer for the condition variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92104 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Stmt.h3
-rw-r--r--lib/AST/Stmt.cpp18
2 files changed, 19 insertions, 2 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index 41b890c14f..fae2e624e9 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -813,6 +813,9 @@ public:
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+protected:
+ virtual void DoDestroy(ASTContext &Ctx);
};
/// DoStmt - This represents a 'do/while' stmt.
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index bb5fba1ee0..dfdb2ce453 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -486,8 +486,22 @@ Stmt::child_iterator SwitchStmt::child_end() {
}
// WhileStmt
-Stmt::child_iterator WhileStmt::child_begin() { return &SubExprs[0]; }
-Stmt::child_iterator WhileStmt::child_end() { return &SubExprs[0]+END_EXPR; }
+Stmt::child_iterator WhileStmt::child_begin() {
+ return child_iterator(Var, &SubExprs[0]);
+}
+Stmt::child_iterator WhileStmt::child_end() {
+ return child_iterator(0, &SubExprs[0]+END_EXPR);
+}
+void WhileStmt::DoDestroy(ASTContext &C) {
+ // We do not use child_iterator here because that will include
+ // the expressions referenced by the condition variable.
+ for (Stmt **I = &SubExprs[0], **E = &SubExprs[END_EXPR]; I != E; ++I)
+ if (Stmt *Child = *I) Child->Destroy(C);
+
+ this->~Stmt();
+ C.Deallocate((void *)this);
+}
+
// DoStmt
Stmt::child_iterator DoStmt::child_begin() { return &SubExprs[0]; }