]> granicus.if.org Git - clang/commitdiff
More of objective-c's gc code-gen. Treat objective-c
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 19 Nov 2008 18:38:10 +0000 (18:38 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 19 Nov 2008 18:38:10 +0000 (18:38 +0000)
objects as __strong when attribute unspecified.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59654 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGValue.h

index 3c283605e11b7db358761bfe43d683cac138fa3d..9e4d66a9478145e142a39695b207cbba8b236d8c 100644 (file)
@@ -542,6 +542,12 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
       ObjCGCAttr::GCAttrTypes attrType = A->getType();
       LValue::SetObjCType(attrType == ObjCGCAttr::Weak, attrType == ObjCGCAttr::Strong, LV);
     }
+    else if (CGM.getLangOptions().ObjC1 &&
+             CGM.getLangOptions().getGCMode() != LangOptions::NonGC) {
+      QualType ExprTy = E->getType();
+      if (getContext().isObjCObjectPointerType(ExprTy))
+        LValue::SetObjCType(false, true, LV);
+    }
     return LV;
   } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(E->getDecl())) {
     return LValue::MakeAddr(CGM.GetAddrOfFunction(FD),
index 1c60ebf14e9c057137fff037bf917b9cf5890b76..5b6283f3c6cecba0590a80e8436fdb50df90f1f6 100644 (file)
@@ -162,10 +162,11 @@ public:
   bool isObjCWeak() const { return ObjCType == Weak; }
   bool isObjCStrong() const { return ObjCType == Strong; }
   
-  static void SetObjCType(unsigned WeakVal, unsigned StrongVal, LValue& R) {
-    if (WeakVal)
+  static void SetObjCType(bool isWeak, bool isStrong, LValue& R) {
+    assert(!(isWeak == true && isStrong == true));
+    if (isWeak)
       R.ObjCType = Weak;
-    else if (StrongVal)
+    else if (isStrong)
       R.ObjCType = Strong;
   }