[cfe-commits] r57299 - /cfe/trunk/Driver/RewriteBlocks.cpp
Steve Naroff
snaroff at apple.com
Wed Oct 8 10:31:16 PDT 2008
Author: snaroff
Date: Wed Oct 8 12:31:13 2008
New Revision: 57299
URL: http://llvm.org/viewvc/llvm-project?rev=57299&view=rev
Log:
Touchup the rewriter to handle the new BlockExpr->BlockDecl dance.
Modified:
cfe/trunk/Driver/RewriteBlocks.cpp
Modified: cfe/trunk/Driver/RewriteBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteBlocks.cpp?rev=57299&r1=57298&r2=57299&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteBlocks.cpp (original)
+++ cfe/trunk/Driver/RewriteBlocks.cpp Wed Oct 8 12:31:13 2008
@@ -630,13 +630,15 @@
SynthesizeBlockLiterals(FunLocStart, FuncName.c_str());
}
-
void RewriteBlocks::GetBlockDeclRefExprs(Stmt *S) {
for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
CI != E; ++CI)
- if (*CI)
- GetBlockDeclRefExprs(*CI);
-
+ if (*CI) {
+ if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI))
+ GetBlockDeclRefExprs(CBE->getBody());
+ else
+ GetBlockDeclRefExprs(*CI);
+ }
// Handle specific things.
if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(S))
// FIXME: Handle enums.
@@ -648,8 +650,12 @@
void RewriteBlocks::GetBlockCallExprs(Stmt *S) {
for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
CI != E; ++CI)
- if (*CI)
- GetBlockCallExprs(*CI);
+ if (*CI) {
+ if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI))
+ GetBlockCallExprs(CBE->getBody());
+ else
+ GetBlockCallExprs(*CI);
+ }
if (CallExpr *CE = dyn_cast<CallExpr>(S)) {
if (CE->getCallee()->getType()->isBlockPointerType()) {
@@ -888,7 +894,7 @@
void RewriteBlocks::CollectBlockDeclRefInfo(BlockExpr *Exp) {
// Add initializers for any closure decl refs.
- GetBlockDeclRefExprs(Exp);
+ GetBlockDeclRefExprs(Exp->getBody());
if (BlockDeclRefs.size()) {
// Unique all "by copy" declarations.
for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
@@ -993,7 +999,7 @@
CI != E; ++CI)
if (*CI) {
if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI)) {
- Stmt *newStmt = RewriteFunctionBody(*CI);
+ Stmt *newStmt = RewriteFunctionBody(CBE->getBody());
if (newStmt)
*CI = newStmt;
@@ -1082,7 +1088,7 @@
RewriteBlockPointerDecl(VD);
if (VD->getInit()) {
if (BlockExpr *CBE = dyn_cast<BlockExpr>(VD->getInit())) {
- RewriteFunctionBody(VD->getInit());
+ RewriteFunctionBody(CBE->getBody());
// We've just rewritten the block body in place.
// Now we snarf the rewritten text and stash it away for later use.
More information about the cfe-commits
mailing list