More objc gc work. Match gcc's treatment of ivar access

true a local pointer to objective-c object in generating
write barriers.

llvm-svn: 65290
This commit is contained in:
Fariborz Jahanian 2009-02-22 18:40:18 +00:00
parent 648c5e9c99
commit 0773533b27
3 changed files with 32 additions and 1 deletions

View File

@ -238,6 +238,10 @@ public:
/// duration. This means that the address of this expression is a link-time
/// constant.
bool hasGlobalStorage() const;
/// isOBJCGCCandidate - Return true if this expression may be used in a read/
/// write barrier.
bool isOBJCGCCandidate() const;
/// IgnoreParens - Ignore parentheses. If this Expr is a ParenExpr, return
/// its subexpression. If that subexpression is also a ParenExpr,

View File

@ -745,6 +745,33 @@ bool Expr::hasGlobalStorage() const {
}
}
/// isOBJCGCCandidate - Check if an expression is objc gc'able.
///
bool Expr::isOBJCGCCandidate() const {
switch (getStmtClass()) {
default:
return false;
case ObjCIvarRefExprClass:
return true;
case ParenExprClass:
return cast<ParenExpr>(this)->getSubExpr()->isOBJCGCCandidate();
case ImplicitCastExprClass:
return cast<ImplicitCastExpr>(this)->getSubExpr()->isOBJCGCCandidate();
case DeclRefExprClass:
case QualifiedDeclRefExprClass: {
const Decl *D = cast<DeclRefExpr>(this)->getDecl();
if (const VarDecl *VD = dyn_cast<VarDecl>(D))
return VD->hasGlobalStorage();
return false;
}
case MemberExprClass: {
const MemberExpr *M = cast<MemberExpr>(this);
return !M->isArrow() && M->getBase()->isOBJCGCCandidate();
}
case ArraySubscriptExprClass:
return cast<ArraySubscriptExpr>(this)->getBase()->isOBJCGCCandidate();
}
}
Expr* Expr::IgnoreParens() {
Expr* E = this;
while (ParenExpr* P = dyn_cast<ParenExpr>(E))

View File

@ -782,7 +782,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
getContext().getObjCGCAttrKind(T));
if (getContext().getLangOptions().ObjC1 &&
getContext().getLangOptions().getGCMode() != LangOptions::NonGC)
LValue::SetObjCNonGC(LV, !E->hasGlobalStorage());
LValue::SetObjCNonGC(LV, !E->isOBJCGCCandidate());
return LV;
}