[cfe-commits] r82061 - in /cfe/trunk: lib/AST/Expr.cpp test/CodeGenObjC/objc2-weak-assign.m

Fariborz Jahanian fjahanian at apple.com
Wed Sep 16 11:09:18 PDT 2009


Author: fjahanian
Date: Wed Sep 16 13:09:18 2009
New Revision: 82061

URL: http://llvm.org/viewvc/llvm-project?rev=82061&view=rev
Log:
Do not generate write-barrier in indirect assignment to
a weak object.

Modified:
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/test/CodeGenObjC/objc2-weak-assign.m

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=82061&r1=82060&r2=82061&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Sep 16 13:09:18 2009
@@ -1117,8 +1117,10 @@
       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;
   }

Modified: cfe/trunk/test/CodeGenObjC/objc2-weak-assign.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc2-weak-assign.m?rev=82061&r1=82060&r2=82061&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenObjC/objc2-weak-assign.m (original)
+++ cfe/trunk/test/CodeGenObjC/objc2-weak-assign.m Wed Sep 16 13:09:18 2009
@@ -9,6 +9,10 @@
 id* __weak a2[30];
 id** __weak a3[40];
 
+void foo (__weak id *param) {
+ *param = 0;
+}
+
 int main()
 {
 	*x = 0;





More information about the cfe-commits mailing list