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/CGValue.h b/lib/CodeGen/CGValue.h
index ef2cb03..c328e35 100644
--- a/lib/CodeGen/CGValue.h
+++ b/lib/CodeGen/CGValue.h
@@ -106,6 +106,12 @@
PropertyRef // This is an Objective-C property reference, use
// getPropertyRefExpr
} LVType;
+
+ enum ObjCType {
+ None = 0, // object with no gc attribute.
+ Weak, // __weak object expression
+ Strong // __strong object expression
+ };
llvm::Value *V;
@@ -130,9 +136,9 @@
bool Volatile:1;
// FIXME: set but never used, what effect should it have?
bool Restrict:1;
-
- bool ObjcWeak:1;
- bool ObjcStrong:1;
+
+ // objective-c's gc attributes
+ unsigned ObjCType : 2;
private:
static void SetQualifiers(unsigned Qualifiers, LValue& R) {
@@ -140,8 +146,7 @@
R.Restrict = (Qualifiers&QualType::Restrict)!=0;
// FIXME: Convenient place to set objc flags to 0. This
// should really be done in a user-defined constructor instead.
- R.ObjcWeak = 0;
- R.ObjcStrong = 0;
+ R.ObjCType = None;
}
public:
@@ -154,12 +159,14 @@
bool isVolatileQualified() const { return Volatile; }
bool isRestrictQualified() const { return Restrict; }
- bool isObjcWeak() const { return ObjcWeak; }
- bool isObjcStrong() const { return ObjcStrong; }
+ bool ObjcWeak() const { return ObjCType == Weak; }
+ bool ObjcStrong() const { return ObjCType == Strong; }
- static void SetObjCGCAttrs(unsigned Weak, unsigned Strong, LValue& R) {
- R.ObjcWeak = Weak;
- R.ObjcStrong = Strong;
+ static void SetObjCType(unsigned WeakVal, unsigned StrongVal, LValue& R) {
+ if (WeakVal)
+ R.ObjCType = Weak;
+ else if (StrongVal)
+ R.ObjCType = Strong;
}
// simple lvalue