]> granicus.if.org Git - clang/commitdiff
Proper rewriting of block envokation with
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 5 Nov 2010 18:34:46 +0000 (18:34 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 5 Nov 2010 18:34:46 +0000 (18:34 +0000)
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

lib/Rewrite/RewriteObjC.cpp
test/Rewriter/rewrite-block-pointer.mm

index 301266f5870140ae4548d6a7c5292aad37b34cf6..5fff38859cbe3348a121eeb05f02aa5ebd6db5e0 100644 (file)
@@ -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);
index 7a90408ccfc47d0c33b35f96a8d4ecb80a637963..abb2f136183c7a8a4fd0a1d70a4e3e847da75760 100644 (file)
@@ -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);
+}
+