<rdar://problem/7263113> Make clang produce gcc's objc_assign_StrongCast as a result of type-cast of an ivar in assignment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83150 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index af8363d..d89da32 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -719,8 +719,18 @@
}
else if (const UnaryOperator *Exp = dyn_cast<UnaryOperator>(E))
setObjCGCLValueClass(Ctx, Exp->getSubExpr(), LV);
- else if (const ParenExpr *Exp = dyn_cast<ParenExpr>(E))
+ else if (const ParenExpr *Exp = dyn_cast<ParenExpr>(E)) {
setObjCGCLValueClass(Ctx, Exp->getSubExpr(), LV);
+ if (LV.isObjCIvar()) {
+ // If cast is to a structure pointer, follow gcc's behavior and make it
+ // a non-ivar write-barrier.
+ QualType ExpTy = E->getType();
+ if (ExpTy->isPointerType())
+ ExpTy = ExpTy->getAs<PointerType>()->getPointeeType();
+ if (ExpTy->isRecordType())
+ LV.SetObjCIvar(LV, false);
+ }
+ }
else if (const ImplicitCastExpr *Exp = dyn_cast<ImplicitCastExpr>(E))
setObjCGCLValueClass(Ctx, Exp->getSubExpr(), LV);
else if (const CStyleCastExpr *Exp = dyn_cast<CStyleCastExpr>(E))