diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-09-26 23:24:14 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-09-26 23:24:14 +0000 |
commit | 9da13f9ddb2567e36f4bbee7b3c32f54aeb76d5b (patch) | |
tree | 0096f7e36fcbb7d048154b528140760cd4366e93 | |
parent | e7b8d400208e886a167a4481a9024295a3ce17d1 (diff) |
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
-rw-r--r-- | include/clang/AST/Expr.h | 6 | ||||
-rw-r--r-- | lib/AST/Expr.cpp | 13 |
2 files changed, 7 insertions, 12 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 9430b51dea..a9c1e68012 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -1492,7 +1492,7 @@ private: 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 @@ public: /// 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()); diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 456b87b64e..6a4b6b0493 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1460,13 +1460,8 @@ Stmt::child_iterator ObjCMessageExpr::child_end() { } // 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(); } |