[cfe-commits] r56288 - in /cfe/trunk: Driver/RewriteBlocks.cpp include/clang/AST/Expr.h include/clang/AST/StmtNodes.def lib/AST/Expr.cpp lib/AST/StmtPrinter.cpp lib/AST/StmtSerialization.cpp lib/Sema/SemaExpr.cpp
Steve Naroff
snaroff at apple.com
Wed Sep 17 11:38:00 PDT 2008
Author: snaroff
Date: Wed Sep 17 13:37:59 2008
New Revision: 56288
URL: http://llvm.org/viewvc/llvm-project?rev=56288&view=rev
Log:
Remove BlockStmtExpr.
Block literals are now represented by the concrete BlockExpr class.
This is cleanup (removes a FIXME).
No functionality change.
Modified:
cfe/trunk/Driver/RewriteBlocks.cpp
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/StmtNodes.def
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtSerialization.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/Driver/RewriteBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteBlocks.cpp?rev=56288&r1=56287&r2=56288&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteBlocks.cpp (original)
+++ cfe/trunk/Driver/RewriteBlocks.cpp Wed Sep 17 13:37:59 2008
@@ -94,7 +94,7 @@
void InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD);
// Block specific rewrite rules.
- void RewriteBlockStmtExpr(BlockStmtExpr *Exp);
+ void RewriteBlockExpr(BlockExpr *Exp);
void RewriteBlockCall(CallExpr *Exp);
void RewriteBlockPointerDecl(NamedDecl *VD);
@@ -349,7 +349,7 @@
// first add the implicit argument.
S += Tag + " *__cself, ";
std::string ParamStr;
- for (BlockStmtExpr::arg_iterator AI = CE->arg_begin(),
+ for (BlockExpr::arg_iterator AI = CE->arg_begin(),
E = CE->arg_end(); AI != E; ++AI) {
if (AI != CE->arg_begin()) S += ", ";
ParamStr = (*AI)->getName();
@@ -398,7 +398,7 @@
(*I)->getType().getAsStringInternal(Name);
S += Name + " = __cself->" + (*I)->getName() + "; // bound by copy\n";
}
- if (BlockStmtExpr *CBE = dyn_cast<BlockStmtExpr>(CE)) {
+ if (BlockExpr *CBE = dyn_cast<BlockExpr>(CE)) {
std::string BodyBuf;
SourceLocation BodyLocStart = CBE->getBody()->getLocStart();
@@ -635,10 +635,10 @@
for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
CI != E; ++CI)
if (*CI) {
- if (BlockStmtExpr *CBE = dyn_cast<BlockStmtExpr>(*CI)) {
+ if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI)) {
// We intentionally avoid rewritting the contents of a closure block
// expr. InsertBlockLiteralsWithinFunction() will rewrite the body.
- RewriteBlockStmtExpr(CBE);
+ RewriteBlockExpr(CBE);
} else {
Stmt *newStmt = RewriteFunctionBody(*CI);
if (newStmt)
@@ -831,7 +831,7 @@
return;
}
-void RewriteBlocks::RewriteBlockStmtExpr(BlockStmtExpr *Exp) {
+void RewriteBlocks::RewriteBlockExpr(BlockExpr *Exp) {
Blocks.push_back(Exp);
bool haveByRefDecls = false;
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=56288&r1=56287&r2=56288&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Sep 17 13:37:59 2008
@@ -1486,21 +1486,29 @@
// Clang Extensions
//===----------------------------------------------------------------------===//
-/// BlockExpr - Common base class between BlockStmtExpr and BlockExprExpr.
-/// FIXME: Combine with BlockStmtExpr...no more need for a common base.
+/// BlockExpr - Represent a block literal with a syntax:
+/// ^{ statement-body } or ^(int arg1, float arg2){ statement-body }
class BlockExpr : public Expr {
SourceLocation CaretLocation;
llvm::SmallVector<ParmVarDecl*, 8> Args;
-protected:
- BlockExpr(StmtClass SC, QualType ty, SourceLocation caretloc,
- ParmVarDecl **args, unsigned numargs)
- : Expr(SC, ty), CaretLocation(caretloc), Args(args, args+numargs) {}
+ CompoundStmt *Body;
public:
+ BlockExpr(SourceLocation caretloc, QualType ty, ParmVarDecl **args,
+ unsigned numargs, CompoundStmt *body) : Expr(BlockExprClass, ty),
+ CaretLocation(caretloc), Args(args, args+numargs), Body(body) {}
+
SourceLocation getCaretLocation() const { return CaretLocation; }
/// getFunctionType - Return the underlying function type for this block.
const FunctionType *getFunctionType() const;
-
+
+ const CompoundStmt *getBody() const { return Body; }
+ CompoundStmt *getBody() { return Body; }
+
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(getCaretLocation(), Body->getLocEnd());
+ }
+
/// arg_iterator - Iterate over the ParmVarDecl's for the arguments to this
/// block.
typedef llvm::SmallVector<ParmVarDecl*, 8>::const_iterator arg_iterator;
@@ -1509,41 +1517,18 @@
arg_iterator arg_end() const { return Args.end(); }
static bool classof(const Stmt *T) {
- return T->getStmtClass() == BlockStmtExprClass;
+ return T->getStmtClass() == BlockExprClass;
}
static bool classof(const BlockExpr *) { return true; }
-};
-/// BlockStmtExpr - Represent a block literal with a syntax:
-/// ^{ statement-body } or ^(int arg1, float arg2){ statement-body }
-class BlockStmtExpr : public BlockExpr {
- CompoundStmt *Body;
-public:
- BlockStmtExpr(SourceLocation CaretLoc, QualType Ty, ParmVarDecl **args,
- unsigned numargs, CompoundStmt *body) :
- BlockExpr(BlockStmtExprClass, Ty, CaretLoc,
- args, numargs), Body(body) {}
-
- const CompoundStmt *getBody() const { return Body; }
- CompoundStmt *getBody() { return Body; }
-
- virtual SourceRange getSourceRange() const {
- return SourceRange(getCaretLocation(), Body->getLocEnd());
- }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == BlockStmtExprClass;
- }
- static bool classof(const BlockStmtExpr *) { return true; }
-
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
virtual void EmitImpl(llvm::Serializer& S) const;
- static BlockStmtExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
+ static BlockExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
};
-
+
/// BlockDeclRefExpr - A reference to a declared variable, function,
/// enum, etc.
class BlockDeclRefExpr : public Expr {
Modified: cfe/trunk/include/clang/AST/StmtNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtNodes.def?rev=56288&r1=56287&r2=56288&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/StmtNodes.def (original)
+++ cfe/trunk/include/clang/AST/StmtNodes.def Wed Sep 17 13:37:59 2008
@@ -110,10 +110,9 @@
STMT(77, OverloadExpr , Expr)
STMT(78, ShuffleVectorExpr , Expr)
STMT(79, BlockExpr , Expr)
-STMT(80, BlockStmtExpr , BlockExpr)
-STMT(81, BlockDeclRefExpr , Expr)
+STMT(80, BlockDeclRefExpr , Expr)
-LAST_EXPR(81)
+LAST_EXPR(80)
#undef STMT
#undef FIRST_STMT
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=56288&r1=56287&r2=56288&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Sep 17 13:37:59 2008
@@ -1448,10 +1448,10 @@
}
// Blocks
-Stmt::child_iterator BlockStmtExpr::child_begin() {
+Stmt::child_iterator BlockExpr::child_begin() {
return reinterpret_cast<Stmt**>(&Body);
}
-Stmt::child_iterator BlockStmtExpr::child_end() {
+Stmt::child_iterator BlockExpr::child_end() {
return reinterpret_cast<Stmt**>(&Body)+1;
}
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=56288&r1=56287&r2=56288&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Wed Sep 17 13:37:59 2008
@@ -891,7 +891,7 @@
const FunctionTypeProto *FT = cast<FunctionTypeProto>(AFT);
OS << '(';
std::string ParamStr;
- for (BlockStmtExpr::arg_iterator AI = Node->arg_begin(),
+ for (BlockExpr::arg_iterator AI = Node->arg_begin(),
E = Node->arg_end(); AI != E; ++AI) {
if (AI != Node->arg_begin()) OS << ", ";
ParamStr = (*AI)->getName();
@@ -907,11 +907,6 @@
}
}
-void StmtPrinter::VisitBlockStmtExpr(BlockStmtExpr *Node) {
- VisitBlockExpr(Node);
- PrintRawCompoundStmt(Node->getBody());
-}
-
void StmtPrinter::VisitBlockDeclRefExpr(BlockDeclRefExpr *Node) {
OS << Node->getDecl()->getName();
}
Modified: cfe/trunk/lib/AST/StmtSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtSerialization.cpp?rev=56288&r1=56287&r2=56288&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/lib/AST/StmtSerialization.cpp Wed Sep 17 13:37:59 2008
@@ -1112,13 +1112,13 @@
// Serialization for Clang Extensions.
//===----------------------------------------------------------------------===//
-void BlockStmtExpr::EmitImpl(Serializer& S) const {
+void BlockExpr::EmitImpl(Serializer& S) const {
S.Emit(getType());
S.Emit(getCaretLocation());
S.EmitOwnedPtr(Body);
}
-BlockStmtExpr* BlockStmtExpr::CreateImpl(Deserializer& D, ASTContext& C) {
+BlockExpr* BlockExpr::CreateImpl(Deserializer& D, ASTContext& C) {
QualType Q = QualType::ReadVal(D);
SourceLocation L = SourceLocation::ReadVal(D);
/*CompoundStmt* BodyStmt = cast<CompoundStmt>(*/D.ReadOwnedPtr<Stmt>(C)/*)*/;
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=56288&r1=56287&r2=56288&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Sep 17 13:37:59 2008
@@ -2886,8 +2886,8 @@
BSI->isVariadic);
BlockTy = Context.getBlockPointerType(BlockTy);
- return new BlockStmtExpr(CaretLoc, BlockTy,
- &BSI->Params[0], BSI->Params.size(), Body.take());
+ return new BlockExpr(CaretLoc, BlockTy, &BSI->Params[0], BSI->Params.size(),
+ Body.take());
}
/// ExprsMatchFnType - return true if the Exprs in array Args have
More information about the cfe-commits
mailing list