]> granicus.if.org Git - clang/commitdiff
objective-c modern translator: synthesize argument type
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 29 Jun 2012 19:55:46 +0000 (19:55 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 29 Jun 2012 19:55:46 +0000 (19:55 +0000)
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

lib/Rewrite/RewriteModernObjC.cpp
test/Rewriter/objc-modern-StretAPI.mm

index a14a9efb78477652b498a59346e7eb673735265b..37e780aba356a33d1a2a044c50ee2808731264b5 100644 (file)
@@ -3108,13 +3108,16 @@ Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFla
   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 @@ void RewriteModernObjC::Initialize(ASTContext &context) {
     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.
index d469dd7862a38c85b3e9beecec4f2a8c5af2a0de..129b56cbe92ddd1d75bcd5a2ef7350228ee9665b 100644 (file)
@@ -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 @@ struct S foo () {
 
   S s3 = [PI() VAMeth : 0, "hello", "there"];
 
+  S s4 = [PI() VAMeth : 2, ^{}, &foo];
+
   return [PI() Meth1];
 }