aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Stmt.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-12-23 23:38:34 +0000
committerTed Kremenek <kremenek@apple.com>2009-12-23 23:38:34 +0000
commit35628d1f17c817f8c240208db7ba490e3109981b (patch)
tree2c10803d84f342eb2fb142b0e836a83095fb4d7b /lib/AST/Stmt.cpp
parent8a69366a1cd8fe1e9fd312048c0d5ce58eabeeb2 (diff)
Add StmtIterator support for iterating over both the condition
variable initializer and the other expressions in an IfStmt. This change required adding a 'DoDestroy()' method for IfStmt that did not include destroying the initializer (since that is owned by the VarDecl). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Stmt.cpp')
-rw-r--r--lib/AST/Stmt.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 14f0c8d744..88950c07b6 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -455,8 +455,21 @@ Stmt::child_iterator LabelStmt::child_begin() { return &SubStmt; }
Stmt::child_iterator LabelStmt::child_end() { return &SubStmt+1; }
// IfStmt
-Stmt::child_iterator IfStmt::child_begin() { return &SubExprs[0]; }
-Stmt::child_iterator IfStmt::child_end() { return &SubExprs[0]+END_EXPR; }
+Stmt::child_iterator IfStmt::child_begin() {
+ return child_iterator(Var, &SubExprs[0]);
+}
+Stmt::child_iterator IfStmt::child_end() {
+ return child_iterator(0, &SubExprs[0]+END_EXPR);
+}
+void IfStmt::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);
+}
// SwitchStmt
Stmt::child_iterator SwitchStmt::child_begin() { return &SubExprs[0]; }