[cfe-commits] r81283 - in /cfe/trunk: lib/AST/Expr.cpp test/CodeGenObjC/objc2-strong-cast-4.m

Fariborz Jahanian fjahanian at apple.com
Tue Sep 8 16:38:54 PDT 2009


Author: fjahanian
Date: Tue Sep  8 18:38:54 2009
New Revision: 81283

URL: http://llvm.org/viewvc/llvm-project?rev=81283&view=rev
Log:
More objc GC's API work for array of pointers declared
as __strong.

Modified:
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m

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

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Sep  8 18:38:54 2009
@@ -1092,7 +1092,7 @@
 }
 
 /// isOBJCGCCandidate - Check if an expression is objc gc'able.
-///
+/// returns true, if it is; false otherwise.
 bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const {
   switch (getStmtClass()) {
   default:
@@ -1114,11 +1114,8 @@
       if (VD->hasGlobalStorage())
         return true;
       QualType T = VD->getType();
-      // dereferencing to an object pointer is always a gc'able candidate
-      if (T->isPointerType() && 
-          T->getAs<PointerType>()->getPointeeType()->isObjCObjectPointerType())
-        return true;
-        
+      // dereferencing to a pointer is always a gc'able candidate
+      return T->isPointerType();
     }
     return false;
   }

Modified: cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m?rev=81283&r1=81282&r2=81283&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m (original)
+++ cfe/trunk/test/CodeGenObjC/objc2-strong-cast-4.m Tue Sep  8 18:38:54 2009
@@ -1,5 +1,5 @@
 // RUN: clang-cc -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s &&
-// RUN: grep objc_assign_strongCast %t | count 3 &&
+// RUN: grep objc_assign_strongCast %t | count 7 &&
 // RUN: true
 
 struct Slice {
@@ -10,14 +10,26 @@
 
 @interface ISlice {
 @public
-    void *__strong * items;
+    void *__strong * IvarItem;
 }
 @end
 
-void foo () {
+void foo (int i) {
+    // storing into an array of strong pointer types.
+    void *__strong* items;
+    items[i] = 0;
+
+    // storing indirectly into an array of strong pointer types.
+    void *__strong* *vitems;
+    *vitems[i] = 0;
+
     Slice *slice;
     slice->items = 0;
+    // storing into a struct element of an array of strong pointer types.
+    slice->items[i] = 0;
 
     ISlice *islice;
-    islice->items = 0;
+    islice->IvarItem = 0;
+    // Storing into an ivar of an array of strong pointer types.
+    islice->IvarItem[i] = (void*)0;
 }





More information about the cfe-commits mailing list