diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-23 18:59:50 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-23 18:59:50 +0000 |
| commit | 207c5210eb0ac7b632609f0c006eb97ef2738948 (patch) | |
| tree | 8c51a1ebf3b23d16b60cd37c1a500b321cee5d68 /lib/CodeGen/CGExpr.cpp | |
| parent | 4262a07621043c19292f5fd90b1e426d65cd366c (diff) | |
| download | clang-207c5210eb0ac7b632609f0c006eb97ef2738948.tar.gz clang-207c5210eb0ac7b632609f0c006eb97ef2738948.tar.bz2 clang-207c5210eb0ac7b632609f0c006eb97ef2738948.tar.xz | |
We should not generate __weak write barrier on indirect reference
of a pointer to object; This patch does this odd behavior according to
gcc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65334 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index c96265242a..0449900a0f 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/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: |
