diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2008-11-19 00:59:10 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2008-11-19 00:59:10 +0000 |
| commit | 58626500527695865683d1d65053743de8770b60 (patch) | |
| tree | e9749fe33e0155b340ed72c05c537184b4e24b53 /lib/CodeGen/CGExpr.cpp | |
| parent | 0a3626444039396802fa35db24733c1963aebfac (diff) | |
| download | clang-58626500527695865683d1d65053743de8770b60.tar.gz clang-58626500527695865683d1d65053743de8770b60.tar.bz2 clang-58626500527695865683d1d65053743de8770b60.tar.xz | |
Generate strong write barriers for __strong objects.
Also, took care of Daniel's commments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59575 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 98a54c6863..95733abbab 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -151,7 +151,7 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) { /// this method emits the address of the lvalue, then loads the result as an /// rvalue, returning the rvalue. RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) { - if (LV.isObjcWeak()) { + if (LV.ObjcWeak()) { // load of a __weak object. llvm::Value *AddrWeakObj = LV.getAddress(); llvm::Value *read_weak = CGM.getObjCRuntime().EmitObjCWeakRead(*this, @@ -335,7 +335,7 @@ RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV, /// is 'Ty'. void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty) { - if (Dst.isObjcWeak()) { + if (Dst.ObjcWeak()) { // load of a __weak object. llvm::Value *LvalueDst = Dst.getAddress(); llvm::Value *src = Src.getScalarVal(); @@ -343,6 +343,14 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, return; } + if (Dst.ObjcStrong()) { + // load of a __strong object. + llvm::Value *LvalueDst = Dst.getAddress(); + llvm::Value *src = Src.getScalarVal(); + CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst); + return; + } + if (!Dst.isSimple()) { if (Dst.isVectorElt()) { // Read/modify/write the vector, inserting the new element. @@ -510,10 +518,9 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { } else if (VD && VD->isFileVarDecl()) { LValue LV = LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD), E->getType().getCVRQualifiers()); - if (VD->getAttr<ObjCGCAttr>()) - { - ObjCGCAttr::GCAttrTypes attrType = (VD->getAttr<ObjCGCAttr>())->getType(); - LValue::SetObjCGCAttrs(attrType == ObjCGCAttr::Weak, attrType == ObjCGCAttr::Strong, LV); + if (const ObjCGCAttr *A = VD->getAttr<ObjCGCAttr>()) { + ObjCGCAttr::GCAttrTypes attrType = A->getType(); + LValue::SetObjCType(attrType == ObjCGCAttr::Weak, attrType == ObjCGCAttr::Strong, LV); } return LV; } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(E->getDecl())) { |
