[cfe-commits] r56710 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/Expr.cpp
Ted Kremenek
kremenek at apple.com
Fri Sep 26 16:24:14 PDT 2008
Author: kremenek
Date: Fri Sep 26 18:24:14 2008
New Revision: 56710
URL: http://llvm.org/viewvc/llvm-project?rev=56710&view=rev
Log:
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).
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=56710&r1=56709&r2=56710&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Sep 26 18:24:14 2008
@@ -1492,7 +1492,7 @@
class BlockExpr : public Expr {
SourceLocation CaretLocation;
llvm::SmallVector<ParmVarDecl*, 8> Args;
- CompoundStmt *Body;
+ Stmt *Body;
public:
BlockExpr(SourceLocation caretloc, QualType ty, ParmVarDecl **args,
unsigned numargs, CompoundStmt *body) : Expr(BlockExprClass, ty),
@@ -1503,8 +1503,8 @@
/// getFunctionType - Return the underlying function type for this block.
const FunctionType *getFunctionType() const;
- const CompoundStmt *getBody() const { return Body; }
- CompoundStmt *getBody() { return Body; }
+ const CompoundStmt *getBody() const { return cast<CompoundStmt>(Body); }
+ CompoundStmt *getBody() { return cast<CompoundStmt>(Body); }
virtual SourceRange getSourceRange() const {
return SourceRange(getCaretLocation(), Body->getLocEnd());
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=56710&r1=56709&r2=56710&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Sep 26 18:24:14 2008
@@ -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 BlockDeclRefExpr::child_begin(){return child_iterator();}
-Stmt::child_iterator BlockDeclRefExpr::child_end() { return child_iterator();}
+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(); }
More information about the cfe-commits
mailing list