[cfe-commits] r92104 - in /cfe/trunk: include/clang/AST/Stmt.h lib/AST/Stmt.cpp
Ted Kremenek
kremenek at apple.com
Wed Dec 23 16:54:19 PST 2009
Author: kremenek
Date: Wed Dec 23 18:54:19 2009
New Revision: 92104
URL: http://llvm.org/viewvc/llvm-project?rev=92104&view=rev
Log:
Modify WhileStmt::child_begin()/child_end() to include the initializer for the condition variable.
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/Stmt.cpp
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=92104&r1=92103&r2=92104&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Wed Dec 23 18:54:19 2009
@@ -813,6 +813,9 @@
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
+
+protected:
+ virtual void DoDestroy(ASTContext &Ctx);
};
/// DoStmt - This represents a 'do/while' stmt.
Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=92104&r1=92103&r2=92104&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Wed Dec 23 18:54:19 2009
@@ -486,8 +486,22 @@
}
// 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]; }
More information about the cfe-commits
mailing list