[cfe-commits] r41511 - /cfe/trunk/AST/Stmt.cpp

Ted Kremenek kremenek at apple.com
Mon Aug 27 13:58:16 PDT 2007


Author: kremenek
Date: Mon Aug 27 15:58:16 2007
New Revision: 41511

URL: http://llvm.org/viewvc/llvm-project?rev=41511&view=rev
Log:
Fixed bug in child_begin/child_end for ReturnStmt where the iterator
would be invalid when RetValExp == NULL.

Modified:
    cfe/trunk/AST/Stmt.cpp

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

==============================================================================
--- cfe/trunk/AST/Stmt.cpp (original)
+++ cfe/trunk/AST/Stmt.cpp Mon Aug 27 15:58:16 2007
@@ -145,9 +145,13 @@
 Stmt::child_iterator BreakStmt::child_end() { return NULL; }
 
 // ReturnStmt
-Stmt::child_iterator ReturnStmt::child_begin() { 
-  return reinterpret_cast<Stmt**>(&RetExpr); 
+Stmt::child_iterator ReturnStmt::child_begin() {
+  if (RetExpr) return reinterpret_cast<Stmt**>(&RetExpr);
+  else return NULL;
 }
 
-Stmt::child_iterator ReturnStmt::child_end() { return child_begin()+1; }
+Stmt::child_iterator ReturnStmt::child_end() { 
+  if (RetExpr) return reinterpret_cast<Stmt**>(&RetExpr)+1;
+  else return NULL;
+}
 





More information about the cfe-commits mailing list