We should not generate __weak write barrier on indirect reference
of a pointer to object; This patch does this odd behavior according to gcc. llvm-svn: 65334
This commit is contained in:
parent
a94e52c687
commit
392124c78e
|
@ -753,6 +753,8 @@ bool Expr::isOBJCGCCandidate() const {
|
||||||
return false;
|
return false;
|
||||||
case ObjCIvarRefExprClass:
|
case ObjCIvarRefExprClass:
|
||||||
return true;
|
return true;
|
||||||
|
case Expr::UnaryOperatorClass:
|
||||||
|
return cast<UnaryOperator>(this)->getSubExpr()->isOBJCGCCandidate();
|
||||||
case ParenExprClass:
|
case ParenExprClass:
|
||||||
return cast<ParenExpr>(this)->getSubExpr()->isOBJCGCCandidate();
|
return cast<ParenExpr>(this)->getSubExpr()->isOBJCGCCandidate();
|
||||||
case ImplicitCastExprClass:
|
case ImplicitCastExprClass:
|
||||||
|
|
|
@ -669,10 +669,19 @@ LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
|
||||||
case UnaryOperator::Deref:
|
case UnaryOperator::Deref:
|
||||||
{
|
{
|
||||||
QualType T = E->getSubExpr()->getType()->getAsPointerType()->getPointeeType();
|
QualType T = E->getSubExpr()->getType()->getAsPointerType()->getPointeeType();
|
||||||
return LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()),
|
LValue LV = LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()),
|
||||||
ExprTy->getAsPointerType()->getPointeeType()
|
ExprTy->getAsPointerType()->getPointeeType()
|
||||||
.getCVRQualifiers(),
|
.getCVRQualifiers(),
|
||||||
getContext().getObjCGCAttrKind(T));
|
getContext().getObjCGCAttrKind(T));
|
||||||
|
// We should not generate __weak write barrier on indirect reference
|
||||||
|
// of a pointer to object; as in void foo (__weak id *param); *param = 0;
|
||||||
|
// But, we continue to generate __strong write barrier on indirect write
|
||||||
|
// into a pointer to object.
|
||||||
|
if (getContext().getLangOptions().ObjC1 &&
|
||||||
|
getContext().getLangOptions().getGCMode() != LangOptions::NonGC &&
|
||||||
|
LV.isObjCWeak())
|
||||||
|
LValue::SetObjCNonGC(LV, !E->isOBJCGCCandidate());
|
||||||
|
return LV;
|
||||||
}
|
}
|
||||||
case UnaryOperator::Real:
|
case UnaryOperator::Real:
|
||||||
case UnaryOperator::Imag:
|
case UnaryOperator::Imag:
|
||||||
|
|
Loading…
Reference in New Issue