diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-11-05 18:34:46 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-11-05 18:34:46 +0000 |
commit | 8188e5f6367714e0eda2bdf9a9710131cb15bbfb (patch) | |
tree | b0dbcccf1160ba50748b68c3b1f902ff72de269e | |
parent | abdce7abc8a22dd2fe79a05c0b71864039bd8296 (diff) |
Proper rewriting of block envokation with
qualified ObjC pointer types in its argument list.
// rdar: //8608902
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118286 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Rewrite/RewriteObjC.cpp | 14 | ||||
-rw-r--r-- | test/Rewriter/rewrite-block-pointer.mm | 6 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index 301266f587..5fff38859c 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -404,6 +404,16 @@ namespace { return false; } + void convertToUnqualifiedObjCType(QualType &T) { + if (T->isObjCQualifiedIdType()) + T = Context->getObjCIdType(); + else if (T->isObjCQualifiedClassType()) + T = Context->getObjCClassType(); + else if (T->isObjCObjectPointerType() && + T->getPointeeType()->isObjCQualifiedInterfaceType()) + T = Context->getObjCIdType(); + } + // FIXME: This predicate seems like it would be useful to add to ASTContext. bool isObjCType(QualType T) { if (!LangOpts.ObjC1 && !LangOpts.ObjC2) @@ -4685,7 +4695,8 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) { E = FTP->arg_type_end(); I && (I != E); ++I) { QualType t = *I; // Make sure we convert "t (^)(...)" to "t (*)(...)". - (void)convertBlockPointerToFunctionPointer(t); + if (!convertBlockPointerToFunctionPointer(t)) + convertToUnqualifiedObjCType(t); ArgTypes.push_back(t); } } @@ -4711,6 +4722,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) { MemberExpr *ME = new (Context) MemberExpr(PE, true, FD, SourceLocation(), FD->getType()); + CastExpr *FunkCast = NoTypeInfoCStyleCastExpr(Context, PtrToFuncCastType, CK_Unknown, ME); PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), FunkCast); diff --git a/test/Rewriter/rewrite-block-pointer.mm b/test/Rewriter/rewrite-block-pointer.mm index 7a90408ccf..abb2f13618 100644 --- a/test/Rewriter/rewrite-block-pointer.mm +++ b/test/Rewriter/rewrite-block-pointer.mm @@ -82,3 +82,9 @@ typedef void (^DVDisc)(id<CoreDAVAccountInfoProvider> discoveredInfo, id<CodePro @interface I @end @interface INTF @end void (^BLINT)(I<CoreDAVAccountInfoProvider>* ARG, INTF<CodeProvider, CoreDAVAccountInfoProvider>* ARG1); + +void test8608902() { + BDVDiscoveryCompletionHandler ppp; + ppp(1, 0); +} + |