[cfe-commits] r57004 - /cfe/trunk/Driver/RewriteBlocks.cpp
Steve Naroff
snaroff at apple.com
Fri Oct 3 08:38:12 PDT 2008
Author: snaroff
Date: Fri Oct 3 10:38:09 2008
New Revision: 57004
URL: http://llvm.org/viewvc/llvm-project?rev=57004&view=rev
Log:
Rewrite global block expressions.
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=57004&r1=57003&r2=57004&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteBlocks.cpp (original)
+++ cfe/trunk/Driver/RewriteBlocks.cpp Fri Oct 3 10:38:09 2008
@@ -90,7 +90,7 @@
void InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD);
// Block specific rewrite rules.
- void RewriteBlockExpr(BlockExpr *Exp);
+ void RewriteBlockExpr(BlockExpr *Exp, VarDecl *VD=0);
void RewriteBlockCall(CallExpr *Exp);
void RewriteBlockPointerDecl(NamedDecl *VD);
@@ -650,9 +650,16 @@
CurMethodDef = 0;
}
}
- if (ValueDecl *ND = dyn_cast<ValueDecl>(D)) {
- if (isBlockPointerType(ND->getType()))
- RewriteBlockPointerDecl(ND);
+ if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
+ if (isBlockPointerType(VD->getType())) {
+ RewriteBlockPointerDecl(VD);
+ if (VD->getInit()) {
+ if (BlockExpr *BExp = dyn_cast<BlockExpr>(VD->getInit())) {
+ RewriteBlockExpr(BExp, VD);
+ SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(), VD->getName());
+ }
+ }
+ }
return;
}
if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
@@ -961,7 +968,7 @@
return;
}
-void RewriteBlocks::RewriteBlockExpr(BlockExpr *Exp) {
+void RewriteBlocks::RewriteBlockExpr(BlockExpr *Exp, VarDecl *VD) {
Blocks.push_back(Exp);
bool haveByRefDecls = false;
@@ -989,7 +996,9 @@
std::string::size_type loc = 0;
while ((loc = FuncName.find(":", loc)) != std::string::npos)
FuncName.replace(loc, 1, "_");
- }
+ } else if (VD)
+ FuncName = std::string(VD->getName());
+
std::string BlockNumber = utostr(Blocks.size()-1);
std::string Tag = "__" + FuncName + "_block_impl_" + BlockNumber;
More information about the cfe-commits
mailing list