From 1c1afc4ed3ec30fc99e172220c8bb74a13b117b0 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 18 Sep 2009 00:04:00 +0000 Subject: Fixed a bug in generation of the new write-barriers when array syntax is used to derefernce and assign to ivar pointee. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82183 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index fa3e492416..43224bb424 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -697,6 +697,7 @@ void setObjCGCLValueClass(const ASTContext &Ctx, const Expr *E, LValue &LV) { if (isa(E)) { LV.SetObjCIvar(LV, true); + LV.SetObjCIvarArray(LV, E->getType()->isArrayType()); return; } if (const DeclRefExpr *Exp = dyn_cast(E)) { @@ -714,10 +715,19 @@ void setObjCGCLValueClass(const ASTContext &Ctx, const Expr *E, LValue &LV) { setObjCGCLValueClass(Ctx, Exp->getSubExpr(), LV); else if (const CStyleCastExpr *Exp = dyn_cast(E)) setObjCGCLValueClass(Ctx, Exp->getSubExpr(), LV); - else if (const ArraySubscriptExpr *Exp = dyn_cast(E)) + else if (const ArraySubscriptExpr *Exp = dyn_cast(E)) { setObjCGCLValueClass(Ctx, Exp->getBase(), LV); + if (LV.isObjCIvar() && !LV.isObjCIvarArray()) { + // Using array syntax to assigning to what an ivar points to is not + // same as assigning to the ivar itself. {id *Names;} Names[i] = 0; + LV.SetObjCIvar(LV, false); + } + } else if (const MemberExpr *Exp = dyn_cast(E)) { setObjCGCLValueClass(Ctx, Exp->getBase(), LV); + // We don't know if member is an 'ivar', but this flag is looked at + // only in the context of LV.isObjCIvar(). + LV.SetObjCIvarArray(LV, E->getType()->isArrayType()); } } -- cgit v1.2.3