]> granicus.if.org Git - clang/commitdiff
Do not generate write-barrier in indirect assignment to
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 16 Sep 2009 18:09:18 +0000 (18:09 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 16 Sep 2009 18:09:18 +0000 (18:09 +0000)
a weak object.

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

lib/AST/Expr.cpp
test/CodeGenObjC/objc2-weak-assign.m

index 0ac896c78388da347285273ec7f422150d2c56ff..4f2d47ec2f42d1765740f47831a5e1b1973d2612 100644 (file)
@@ -1117,8 +1117,10 @@ bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const {
       if (VD->hasGlobalStorage())
         return true;
       QualType T = VD->getType();
-      // dereferencing to a pointer is always a gc'able candidate
-      return T->isPointerType();
+      // dereferencing to a  pointer is always a gc'able candidate,
+      // unless it is __weak.
+      return T->isPointerType() && 
+             (Ctx.getObjCGCAttrKind(T) != QualType::Weak);
     }
     return false;
   }
index a3740b207e85da493dd01efcb0b3c253c164f596..635ca38df46c77edd4f8ee9d6386426c02b5a5b4 100644 (file)
@@ -9,6 +9,10 @@ __weak id* a1[20];
 id* __weak a2[30];
 id** __weak a3[40];
 
+void foo (__weak id *param) {
+ *param = 0;
+}
+
 int main()
 {
        *x = 0;