summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-02-23 18:59:50 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-02-23 18:59:50 +0000
commit392124c78e6ad8c9e5dbe1dac66fb3ad1a206971 (patch)
tree1bed5d703e86af796a47cdc48f4abff76593269e /clang/lib/CodeGen
parenta94e52c687ec2f982d32c2cebad1555ebbe47b26 (diff)
downloadbcm5719-llvm-392124c78e6ad8c9e5dbe1dac66fb3ad1a206971.tar.gz
bcm5719-llvm-392124c78e6ad8c9e5dbe1dac66fb3ad1a206971.zip
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
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index c96265242ac..0449900a0f8 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -669,10 +669,19 @@ LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
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:
OpenPOWER on IntegriCloud