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
This commit is contained in:
Fariborz Jahanian 2012-06-29 19:55:46 +00:00
parent 49f6dacd45
commit 6734ec41ab
2 changed files with 10 additions and 6 deletions

View 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.

View 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];
}