Internally store the body of a BlockExpr using a Stmt* instead of a CompoundStmt*, and use the getBody() method to do the appropriate checking. This both removes the type-punning warnings in Expr.cpp and also makes BlockExpr have more consistency checks against modifications to its body (via StmtIterator).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56710 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 456b87b..6a4b6b0 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -1460,13 +1460,8 @@
}
// Blocks
-Stmt::child_iterator BlockExpr::child_begin() {
- return reinterpret_cast<Stmt**>(&Body);
-}
-Stmt::child_iterator BlockExpr::child_end() {
- return reinterpret_cast<Stmt**>(&Body)+1;
-}
+Stmt::child_iterator BlockExpr::child_begin() { return &Body; }
+Stmt::child_iterator BlockExpr::child_end() { return &Body+1; }
-Stmt::child_iterator BlockDeclRefExpr::child_begin(){return child_iterator();}
-Stmt::child_iterator BlockDeclRefExpr::child_end() { return child_iterator();}
-
+Stmt::child_iterator BlockDeclRefExpr::child_begin() { return child_iterator();}
+Stmt::child_iterator BlockDeclRefExpr::child_end() { return child_iterator(); }