diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-09-18 00:04:00 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-09-18 00:04:00 +0000 |
commit | 2e32ddc7bac1c99b68f537bb7ba30b40a3437a45 (patch) | |
tree | 14eb1f125919dca19d0015c29a7c3efecbef4898 /clang/lib | |
parent | 7fc4ad6a63257a978f230f481177b14a194dca73 (diff) | |
download | bcm5719-llvm-2e32ddc7bac1c99b68f537bb7ba30b40a3437a45.tar.gz bcm5719-llvm-2e32ddc7bac1c99b68f537bb7ba30b40a3437a45.zip |
Fixed a bug in generation of the new write-barriers when
array syntax is used to derefernce and assign to ivar pointee.
llvm-svn: 82183
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 12 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGValue.h | 10 |
2 files changed, 19 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index fa3e4924168..43224bb424c 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -697,6 +697,7 @@ void setObjCGCLValueClass(const ASTContext &Ctx, const Expr *E, LValue &LV) { if (isa<ObjCIvarRefExpr>(E)) { LV.SetObjCIvar(LV, true); + LV.SetObjCIvarArray(LV, E->getType()->isArrayType()); return; } if (const DeclRefExpr *Exp = dyn_cast<DeclRefExpr>(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<CStyleCastExpr>(E)) setObjCGCLValueClass(Ctx, Exp->getSubExpr(), LV); - else if (const ArraySubscriptExpr *Exp = dyn_cast<ArraySubscriptExpr>(E)) + else if (const ArraySubscriptExpr *Exp = dyn_cast<ArraySubscriptExpr>(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<MemberExpr>(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()); } } diff --git a/clang/lib/CodeGen/CGValue.h b/clang/lib/CodeGen/CGValue.h index fe97afad6e8..af034a7ad59 100644 --- a/clang/lib/CodeGen/CGValue.h +++ b/clang/lib/CodeGen/CGValue.h @@ -152,6 +152,9 @@ class LValue { // objective-c's ivar bool Ivar:1; + + // objective-c's ivar is an array + bool IvarArray:1; // LValue is non-gc'able for any reason, including being a parameter or local // variable. @@ -173,7 +176,7 @@ private: // FIXME: Convenient place to set objc flags to 0. This should really be // done in a user-defined constructor instead. R.ObjCType = None; - R.Ivar = R.NonGC = R.GlobalObjCRef = false; + R.Ivar = R.IvarArray = R.NonGC = R.GlobalObjCRef = false; } public: @@ -192,6 +195,7 @@ public: } bool isObjCIvar() const { return Ivar; } + bool isObjCIvarArray() const { return IvarArray; } bool isNonGC () const { return NonGC; } bool isGlobalObjCRef() const { return GlobalObjCRef; } bool isObjCWeak() const { return ObjCType == Weak; } @@ -202,7 +206,9 @@ public: static void SetObjCIvar(LValue& R, bool iValue) { R.Ivar = iValue; } - + static void SetObjCIvarArray(LValue& R, bool iValue) { + R.IvarArray = iValue; + } static void SetGlobalObjCRef(LValue& R, bool iValue) { R.GlobalObjCRef = iValue; } |