- 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/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index 844a3e8..ba67a97 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -895,26 +895,27 @@
 }
 
 void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
+  BlockDecl *BD = Node->getBlockDecl();
   OS << "^";
   
   const FunctionType *AFT = Node->getFunctionType();
   
   if (isa<FunctionTypeNoProto>(AFT)) {
     OS << "()";
-  } else if (!Node->arg_empty() || cast<FunctionTypeProto>(AFT)->isVariadic()) {
-    const FunctionTypeProto *FT = cast<FunctionTypeProto>(AFT);
+  } else if (!BD->param_empty() || cast<FunctionTypeProto>(AFT)->isVariadic()) {
     OS << '(';
     std::string ParamStr;
-    for (BlockExpr::arg_iterator AI = Node->arg_begin(),
-         E = Node->arg_end(); AI != E; ++AI) {
-      if (AI != Node->arg_begin()) OS << ", ";
+    for (BlockDecl::param_iterator AI = BD->param_begin(),
+         E = BD->param_end(); AI != E; ++AI) {
+      if (AI != BD->param_begin()) OS << ", ";
       ParamStr = (*AI)->getName();
       (*AI)->getType().getAsStringInternal(ParamStr);
       OS << ParamStr;
     }
     
+    const FunctionTypeProto *FT = cast<FunctionTypeProto>(AFT);
     if (FT->isVariadic()) {
-      if (!Node->arg_empty()) OS << ", ";
+      if (!BD->param_empty()) OS << ", ";
       OS << "...";
     }
     OS << ')';