[cfe-commits] r58262 - /cfe/trunk/Driver/RewriteObjC.cpp
Steve Naroff
snaroff at apple.com
Mon Oct 27 11:50:14 PDT 2008
Author: snaroff
Date: Mon Oct 27 13:50:14 2008
New Revision: 58262
URL: http://llvm.org/viewvc/llvm-project?rev=58262&view=rev
Log:
Some fixups to the previous objc/blocks rewriter smerge.
Modified:
cfe/trunk/Driver/RewriteObjC.cpp
Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=58262&r1=58261&r2=58262&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Mon Oct 27 13:50:14 2008
@@ -456,10 +456,6 @@
Preamble += "#endif\n";
Preamble += "#define __NSCONSTANTSTRINGIMPL\n";
Preamble += "#endif\n";
- if (LangOpts.Microsoft) {
- Preamble += "#undef __OBJC_RW_EXTERN\n";
- Preamble += "#define __attribute__(X)\n";
- }
// Blocks preamble.
Preamble += "#ifndef BLOCK_IMPL\n";
Preamble += "#define BLOCK_IMPL\n";
@@ -473,10 +469,6 @@
Preamble += " BLOCK_HAS_COPY_DISPOSE = (1<<25),\n";
Preamble += " BLOCK_IS_GLOBAL = (1<<28)\n";
Preamble += "};\n";
- if (LangOpts.Microsoft)
- Preamble += "#define __OBJC_RW_EXTERN extern \"C\" __declspec(dllimport)\n";
- else
- Preamble += "#define __OBJC_RW_EXTERN extern\n";
Preamble += "// Runtime copy/destroy helper functions\n";
Preamble += "__OBJC_RW_EXTERN void _Block_copy_assign(void *, void *);\n";
Preamble += "__OBJC_RW_EXTERN void _Block_byref_assign_copy(void *, void *);\n";
@@ -485,6 +477,10 @@
Preamble += "__OBJC_RW_EXTERN void *_NSConcreteGlobalBlock;\n";
Preamble += "__OBJC_RW_EXTERN void *_NSConcreteStackBlock;\n";
Preamble += "#endif\n";
+ if (LangOpts.Microsoft) {
+ Preamble += "#undef __OBJC_RW_EXTERN\n";
+ Preamble += "#define __attribute__(X)\n";
+ }
}
@@ -1138,9 +1134,23 @@
for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
CI != E; ++CI)
if (*CI) {
- Stmt *newStmt = RewriteFunctionBodyOrGlobalInitializer(*CI);
- if (newStmt)
- *CI = newStmt;
+ if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI)) {
+ Stmt *newStmt = RewriteFunctionBodyOrGlobalInitializer(CBE->getBody());
+ if (newStmt)
+ *CI = newStmt;
+
+ // We've just rewritten the block body in place.
+ // Now we snarf the rewritten text and stash it away for later use.
+ std::string S = Rewrite.getRewritenText(CBE->getSourceRange());
+ RewrittenBlockExprs[CBE] = S;
+ std::string Init = SynthesizeBlockInitExpr(CBE);
+ // Do the rewrite, using S.size() which contains the rewritten size.
+ ReplaceText(CBE->getLocStart(), S.size(), Init.c_str(), Init.size());
+ } else {
+ Stmt *newStmt = RewriteFunctionBodyOrGlobalInitializer(*CI);
+ if (newStmt)
+ *CI = newStmt;
+ }
}
// Handle specific things.
More information about the cfe-commits
mailing list