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
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 98a54c6..95733ab 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -151,7 +151,7 @@
/// 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 @@
/// 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 @@
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 @@
} 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())) {