diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-12-24 00:39:05 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-12-24 00:39:05 +0000 |
commit | a3be0eaa5c253bbf1e4eb61b0a3a9c869b94aee9 (patch) | |
tree | b645537564404edb7116882de066ce97635f2d5d | |
parent | cb1c77f90d4e747b83a0d0cc125dc01567378f82 (diff) |
Modify SwitchStmt::child_begin()/child_end() to include the initializer for the condition variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92100 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Stmt.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index 88950c07b6..bb5fba1ee0 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -103,8 +103,14 @@ void SwitchStmt::DoDestroy(ASTContext &Ctx) { SC->Destroy(Ctx); SC = Next; } - - Stmt::DoDestroy(Ctx); + + // 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(Ctx); + + this->~Stmt(); + Ctx.Deallocate((void *)this); } void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) { @@ -472,8 +478,12 @@ void IfStmt::DoDestroy(ASTContext &C) { } // SwitchStmt -Stmt::child_iterator SwitchStmt::child_begin() { return &SubExprs[0]; } -Stmt::child_iterator SwitchStmt::child_end() { return &SubExprs[0]+END_EXPR; } +Stmt::child_iterator SwitchStmt::child_begin() { + return child_iterator(Var, &SubExprs[0]); +} +Stmt::child_iterator SwitchStmt::child_end() { + return child_iterator(0, &SubExprs[0]+END_EXPR); +} // WhileStmt Stmt::child_iterator WhileStmt::child_begin() { return &SubExprs[0]; } |