diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-05-04 23:27:20 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-05-04 23:27:20 +0000 |
commit | bf63b87ecf1e62ab8871a81325978377c84e1835 (patch) | |
tree | 933c97b0606fb1708c15339c5e6e6ba54e018191 /lib/CodeGen | |
parent | 6e8575b88bfb2634d7b28c0c4d5ed2a6acc8418a (diff) |
Provide basic support for generation of objc2's
objc_assign_global API when assigning to global
objective-c object pointer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70939 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 7 | ||||
-rw-r--r-- | lib/CodeGen/CGValue.h | 11 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 2bcb362f18..74d736490a 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -442,7 +442,10 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, else CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst); #endif - CGM.getObjCRuntime().EmitObjCStrongCastAssign(*this, src, LvalueDst); + if (Dst.isGlobalObjCRef()) + CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst); + else + CGM.getObjCRuntime().EmitObjCStrongCastAssign(*this, src, LvalueDst); return; } @@ -666,6 +669,8 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { LValue LV = LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD), E->getType().getCVRQualifiers(), getContext().getObjCGCAttrKind(E->getType())); + if (LV.isObjCStrong()) + LV.SetGlobalObjCRef(LV, true); return LV; } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(E->getDecl())) { return LValue::MakeAddr(CGM.GetAddrOfFunction(FD), diff --git a/lib/CodeGen/CGValue.h b/lib/CodeGen/CGValue.h index 66cb0037a1..5204c45166 100644 --- a/lib/CodeGen/CGValue.h +++ b/lib/CodeGen/CGValue.h @@ -149,8 +149,12 @@ class LValue { // variable. bool NonGC: 1; + // Lvalue is a global reference of an objective-c object + bool GlobalObjCRef : 1; + // objective-c's gc attributes unsigned ObjCType : 2; + private: @@ -160,7 +164,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 = false; + R.Ivar = R.NonGC = R.GlobalObjCRef = false; } public: @@ -180,12 +184,17 @@ public: bool isObjCIvar() const { return Ivar; } bool isNonGC () const { return NonGC; } + bool isGlobalObjCRef() const { return GlobalObjCRef; } bool isObjCWeak() const { return ObjCType == Weak; } bool isObjCStrong() const { return ObjCType == Strong; } static void SetObjCIvar(LValue& R, bool iValue) { R.Ivar = iValue; } + + static void SetGlobalObjCRef(LValue& R, bool iValue) { + R.GlobalObjCRef = iValue; + } static void SetObjCNonGC(LValue& R, bool iValue) { R.NonGC = iValue; |