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 | d7db9644955fe5a4590b72e7cf5524c5952ea018 (patch) | |
tree | 253a0b1a489d9a5dc6e2e1843ce7522dafe6e1ac /clang/lib/CodeGen/CGExpr.cpp | |
parent | 1b167108bbbf206e9d336fa3028d53d38f88adde (diff) | |
download | bcm5719-llvm-d7db9644955fe5a4590b72e7cf5524c5952ea018.tar.gz bcm5719-llvm-d7db9644955fe5a4590b72e7cf5524c5952ea018.zip |
Generate strong write barriers for __strong objects.
Also, took care of Daniel's commments.
llvm-svn: 59575
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 98a54c6863f..95733abbab4 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/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())) { |