objective-c modern translator: synthesize argument type
correctly for blocks and function pointer arguments
in the written constructor.  // rdar://11359268


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159456 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Rewrite/RewriteModernObjC.cpp b/lib/Rewrite/RewriteModernObjC.cpp
index a14a9ef..37e780a 100644
--- a/lib/Rewrite/RewriteModernObjC.cpp
+++ b/lib/Rewrite/RewriteModernObjC.cpp
@@ -3108,13 +3108,16 @@
   str += name;
   str += "(id receiver, SEL sel";
   for (unsigned i = 2; i < ArgTypes.size(); i++) {
-    str += ", "; str += ArgTypes[i].getAsString(Context->getPrintingPolicy());
-    str += " arg"; str += utostr(i);
+    std::string ArgName = "arg"; ArgName += utostr(i);
+    ArgTypes[i].getAsStringInternal(ArgName, Context->getPrintingPolicy());
+    str += ", "; str += ArgName;
   }
   // could be vararg.
   for (unsigned i = ArgTypes.size(); i < MsgExprs.size(); i++) {
-    str += ", "; str += MsgExprs[i]->getType().getAsString(Context->getPrintingPolicy());
-    str += " arg"; str += utostr(i);
+    std::string ArgName = "arg"; ArgName += utostr(i);
+    MsgExprs[i]->getType().getAsStringInternal(ArgName,
+                                               Context->getPrintingPolicy());
+    str += ", "; str += ArgName;
   }
   
   str += ") {\n";
@@ -5956,8 +5959,6 @@
     Preamble += "#define __block\n";
     Preamble += "#define __weak\n";
   }
-  
-  // needed for use of memset.
   Preamble += "\nextern \"C\" void * memset(void *b, int c, unsigned long len);\n";
   
   // Declarations required for modern objective-c array and dictionary literals.
diff --git a/test/Rewriter/objc-modern-StretAPI.mm b/test/Rewriter/objc-modern-StretAPI.mm
index d469dd7..129b56c 100644
--- a/test/Rewriter/objc-modern-StretAPI.mm
+++ b/test/Rewriter/objc-modern-StretAPI.mm
@@ -3,6 +3,7 @@
 // rdar://11359268
 
 extern "C" void *sel_registerName(const char *);
+typedef unsigned long size_t;
 
 union U {
   double d1;
@@ -35,6 +36,8 @@
 
   S s3 = [PI() VAMeth : 0, "hello", "there"];
 
+  S s4 = [PI() VAMeth : 2, ^{}, &foo];
+
   return [PI() Meth1];
 }