objc-gc: Fix a corner case where clang fails to generate GC

write barrier with captured pointer to object. // rdar://10150823

llvm-svn: 140399
This commit is contained in:
Fariborz Jahanian 2011-09-23 18:57:30 +00:00
parent 947961c151
commit c367b8f8cc
2 changed files with 33 additions and 1 deletions

View File

@ -1728,8 +1728,15 @@ bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const {
->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;

View File

@ -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
@interface Test {
@package
Test ** __strong objects;
}
@end
id newObject();
void runWithBlock(void(^)(int i));
@implementation Test
- (void)testWithObjectInBlock {
Test **children = objects;
runWithBlock(^(int i){
children[i] = newObject();
});
}
@end
// CHECK: call i8* @objc_assign_strongCast
// CHECK: call i8* @objc_assign_strongCast