]> granicus.if.org Git - clang/commitdiff
Patch to remove arbitrary imporation of 'self' into
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 17 Feb 2010 19:54:08 +0000 (19:54 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 17 Feb 2010 19:54:08 +0000 (19:54 +0000)
a block without it being used. This causes over release
of objects in certain runtime-senitive apps.
(fixes radar 7581175).

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

lib/CodeGen/CGBlocks.cpp
test/CodeGenObjC/blocks-5.m [new file with mode: 0644]

index 46b62441d6e452b7d7158005f140a32864f776f5..2f0961326a179fe7cc15fe6ae4ccd2b8cae1bab9 100644 (file)
@@ -110,19 +110,6 @@ static bool CanBlockBeGlobal(const CodeGenFunction::BlockInfo &Info) {
 /// invoke function.
 static void AllocateAllBlockDeclRefs(const CodeGenFunction::BlockInfo &Info,
                                      CodeGenFunction *CGF) {
-  // Always allocate self, as it is often handy in the debugger, even if there
-  // is no codegen in the block that uses it.  This is also useful to always do
-  // this as if we didn't, we'd have to figure out all code that uses a self
-  // pointer, including implicit uses.
-  if (const ObjCMethodDecl *OMD
-      = dyn_cast_or_null<ObjCMethodDecl>(CGF->CurFuncDecl)) {
-    ImplicitParamDecl *SelfDecl = OMD->getSelfDecl();
-    BlockDeclRefExpr *BDRE = new (CGF->getContext())
-      BlockDeclRefExpr(SelfDecl,
-                       SelfDecl->getType(), SourceLocation(), false);
-    CGF->AllocateBlockDecl(BDRE);
-  }
-
   // FIXME: Also always forward the this pointer in C++ as well.
 
   for (size_t i = 0; i < Info.DeclRefs.size(); ++i)
diff --git a/test/CodeGenObjC/blocks-5.m b/test/CodeGenObjC/blocks-5.m
new file mode 100644 (file)
index 0000000..12c381b
--- /dev/null
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// radar 7581175
+
+extern void dispatch_async (void (^)(void));
+
+@interface Foo 
+@end
+
+@implementation Foo
+- (void)dealloc {
+        dispatch_async(^{});
+}
+@end
+
+// CHECK: self.addr
+// CHECK: self.addr