[cfe-commits] r92100 - /cfe/trunk/lib/AST/Stmt.cpp

Ted Kremenek kremenek at apple.com
Wed Dec 23 16:39:05 PST 2009


Author: kremenek
Date: Wed Dec 23 18:39:05 2009
New Revision: 92100

URL: http://llvm.org/viewvc/llvm-project?rev=92100&view=rev
Log:
Modify SwitchStmt::child_begin()/child_end() to include the initializer for the condition variable.

Modified:
    cfe/trunk/lib/AST/Stmt.cpp

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=92100&r1=92099&r2=92100&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Wed Dec 23 18:39:05 2009
@@ -103,8 +103,14 @@
     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 @@
 }
 
 // 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]; }





More information about the cfe-commits mailing list