Fixed bug in child_begin/child_end for ReturnStmt where the iterator

would be invalid when RetValExp == NULL.

llvm-svn: 41511
This commit is contained in:
Ted Kremenek 2007-08-27 20:58:16 +00:00
parent 312b70a970
commit 5b3ed283f5
1 changed files with 7 additions and 3 deletions

View File

@ -145,9 +145,13 @@ Stmt::child_iterator BreakStmt::child_begin() { return NULL; }
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;
}