forked from OSchip/llvm-project
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).
llvm-svn: 56710
This commit is contained in:
parent
2e53c51914
commit
8bafa2cf9f
|
@ -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());
|
||||
|
|
|
@ -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(); }
|
||||
|
|
Loading…
Reference in New Issue