[cfe-commits] r65334 - in /cfe/trunk/lib: AST/Expr.cpp CodeGen/CGExpr.cpp
Fariborz Jahanian
fjahanian at apple.com
Mon Feb 23 10:59:50 PST 2009
Author: fjahanian
Date: Mon Feb 23 12:59:50 2009
New Revision: 65334
URL: http://llvm.org/viewvc/llvm-project?rev=65334&view=rev
Log:
We should not generate __weak write barrier on indirect reference
of a pointer to object; This patch does this odd behavior according to
gcc.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=65334&r1=65333&r2=65334&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Feb 23 12:59:50 2009
@@ -753,6 +753,8 @@
return false;
case ObjCIvarRefExprClass:
return true;
+ case Expr::UnaryOperatorClass:
+ return cast<UnaryOperator>(this)->getSubExpr()->isOBJCGCCandidate();
case ParenExprClass:
return cast<ParenExpr>(this)->getSubExpr()->isOBJCGCCandidate();
case ImplicitCastExprClass:
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=65334&r1=65333&r2=65334&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Feb 23 12:59:50 2009
@@ -669,10 +669,19 @@
case UnaryOperator::Deref:
{
QualType T = E->getSubExpr()->getType()->getAsPointerType()->getPointeeType();
- return LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()),
- ExprTy->getAsPointerType()->getPointeeType()
+ LValue LV = LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()),
+ ExprTy->getAsPointerType()->getPointeeType()
.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::Imag:
More information about the cfe-commits
mailing list