]> granicus.if.org Git - clang/commitdiff
Fix rewriting of a method when return type is
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 24 Feb 2010 01:25:40 +0000 (01:25 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 24 Feb 2010 01:25:40 +0000 (01:25 +0000)
a block pointer type. Fixes radar 7682149.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97008 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 0156d1da91d061e96987abbebfcf516fa4d6141d..521abf489b9067cf8e970bae83d4ebdb39f43a7a 100644 (file)
@@ -2815,6 +2815,10 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
     }
     returnType = OMD->getResultType()->isObjCQualifiedIdType()
                    ? Context->getObjCIdType() : OMD->getResultType();
+    if (isTopLevelBlockPointerType(returnType)) {
+      const BlockPointerType *BPT = returnType->getAs<BlockPointerType>();
+      returnType = Context->getPointerType(BPT->getPointeeType());
+    }
   } else {
     returnType = Context->getObjCIdType();
   }
index 4a4fa347084775ac2c646adf2d85c761bc5e6c47..8698b93c1828b4cc2f356a58c6b24e20ff6e3fb8 100644 (file)
@@ -3,6 +3,7 @@
 // radar 7638400
 
 typedef void * id;
+void *sel_registerName(const char *);
 
 @interface X
 @end
@@ -33,3 +34,27 @@ void *_Block_copy(const void *aBlock);
 void x(void (^block)(void)) {
         block = ((__typeof(block))_Block_copy((const void *)(block)));
 }
+
+// radar 7682149
+@interface Y {
+@private
+    id _private;
+}
+- (void (^)(void))f;
+@end
+
+typedef void (^void_block_t)(void);
+
+@interface YY {
+    void_block_t __completion;
+}
+@property (copy) void_block_t f;
+@end
+
+@implementation Y
+- (void (^)(void))f {
+    return [_private f];
+}
+
+@end
+