[cfe-commits] r140399 - in /cfe/trunk: lib/AST/Expr.cpp test/CodeGenObjC/objc2-strong-cast-block-import.m
Fariborz Jahanian
fjahanian at apple.com
Fri Sep 23 11:57:30 PDT 2011
Author: fjahanian
Date: Fri Sep 23 13:57:30 2011
New Revision: 140399
URL: http://llvm.org/viewvc/llvm-project?rev=140399&view=rev
Log:
objc-gc: Fix a corner case where clang fails to generate GC
write barrier with captured pointer to object. // rdar://10150823
Added:
cfe/trunk/test/CodeGenObjC/objc2-strong-cast-block-import.m
Modified:
cfe/trunk/lib/AST/Expr.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=140399&r1=140398&r2=140399&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Sep 23 13:57:30 2011
@@ -1728,8 +1728,15 @@
->isOBJCGCCandidate(Ctx);
case CStyleCastExprClass:
return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
+ case BlockDeclRefExprClass:
case DeclRefExprClass: {
- const Decl *D = cast<DeclRefExpr>(E)->getDecl();
+
+ const Decl *D;
+ if (const BlockDeclRefExpr *BDRE = dyn_cast<BlockDeclRefExpr>(E))
+ D = BDRE->getDecl();
+ else
+ D = cast<DeclRefExpr>(E)->getDecl();
+
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
if (VD->hasGlobalStorage())
return true;
Added: cfe/trunk/test/CodeGenObjC/objc2-strong-cast-block-import.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc2-strong-cast-block-import.m?rev=140399&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/objc2-strong-cast-block-import.m (added)
+++ cfe/trunk/test/CodeGenObjC/objc2-strong-cast-block-import.m Fri Sep 23 13:57:30 2011
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc-only -fblocks -fobjc-nonfragile-abi -emit-llvm -o - %s | FileCheck %s
+// rdar://10150823
+
+ at interface Test {
+ at package
+ Test ** __strong objects;
+}
+ at end
+
+id newObject();
+void runWithBlock(void(^)(int i));
+
+ at implementation Test
+
+- (void)testWithObjectInBlock {
+ Test **children = objects;
+ runWithBlock(^(int i){
+ children[i] = newObject();
+ });
+}
+
+ at end
+// CHECK: call i8* @objc_assign_strongCast
+// CHECK: call i8* @objc_assign_strongCast
+
More information about the cfe-commits
mailing list