- Add BlockDecl AST node.
- Modify BlockExpr to reference the BlockDecl.
This is "cleanup" necessary to improve our lookup semantics for blocks (to fix <rdar://problem/6272905> clang block rewriter: parameter to function not imported into block?).
Still some follow-up work to finish this (forthcoming).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57298 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/RewriteBlocks.cpp b/Driver/RewriteBlocks.cpp
index 83bc428..45c0715 100644
--- a/Driver/RewriteBlocks.cpp
+++ b/Driver/RewriteBlocks.cpp
@@ -364,9 +364,11 @@
std::string S = "static " + RT.getAsString() + " __" +
funcName + "_" + "block_func_" + utostr(i);
+ BlockDecl *BD = CE->getBlockDecl();
+
if (isa<FunctionTypeNoProto>(AFT)) {
S += "()";
- } else if (CE->arg_empty()) {
+ } else if (BD->param_empty()) {
S += "(" + StructRef + " *__cself)";
} else {
const FunctionTypeProto *FT = cast<FunctionTypeProto>(AFT);
@@ -375,15 +377,15 @@
// first add the implicit argument.
S += StructRef + " *__cself, ";
std::string ParamStr;
- for (BlockExpr::arg_iterator AI = CE->arg_begin(),
- E = CE->arg_end(); AI != E; ++AI) {
- if (AI != CE->arg_begin()) S += ", ";
+ for (BlockDecl::param_iterator AI = BD->param_begin(),
+ E = BD->param_end(); AI != E; ++AI) {
+ if (AI != BD->param_begin()) S += ", ";
ParamStr = (*AI)->getName();
(*AI)->getType().getAsStringInternal(ParamStr);
S += ParamStr;
}
if (FT->isVariadic()) {
- if (!CE->arg_empty()) S += ", ";
+ if (!BD->param_empty()) S += ", ";
S += "...";
}
S += ')';