[cfe-commits] r143887 - in /cfe/trunk: lib/ARCMigrate/TransGCAttrs.cpp test/ARCMT/GC-check.m test/ARCMT/GC.h

Argyrios Kyrtzidis akyrtzi at gmail.com
Sun Nov 6 10:58:23 PST 2011


Author: akirtzidis
Date: Sun Nov  6 12:58:23 2011
New Revision: 143887

URL: http://llvm.org/viewvc/llvm-project?rev=143887&view=rev
Log:
[arcmt] In GC, error for __strong/__weak on non-objc pointers.

Modified:
    cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
    cfe/trunk/test/ARCMT/GC-check.m
    cfe/trunk/test/ARCMT/GC.h

Modified: cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp?rev=143887&r1=143886&r2=143887&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp Sun Nov  6 12:58:23 2011
@@ -186,10 +186,28 @@
   }
 }
 
+static void errorForGCAttrsOnNonObjC(MigrationContext &MigrateCtx) {
+  TransformActions &TA = MigrateCtx.Pass.TA;
+
+  for (unsigned i = 0, e = MigrateCtx.GCAttrs.size(); i != e; ++i) {
+    MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs[i];
+    if (Attr.FullyMigratable && Attr.Dcl) {
+      if (Attr.ModifiedType.isNull())
+        continue;
+      if (!Attr.ModifiedType->isObjCRetainableType()) {
+        TA.reportError("GC managed memory will become unmanaged in ARC",
+                       Attr.Loc);
+      }
+    }
+  }
+}
+
 void GCAttrsTraverser::traverseTU(MigrationContext &MigrateCtx) {
   GCAttrsCollector(MigrateCtx).TraverseDecl(
                                   MigrateCtx.Pass.Ctx.getTranslationUnitDecl());
+
   clearRedundantStrongs(MigrateCtx);
+  errorForGCAttrsOnNonObjC(MigrateCtx);
 }
 
 void MigrationContext::dumpGCAttrs() {

Modified: cfe/trunk/test/ARCMT/GC-check.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/GC-check.m?rev=143887&r1=143886&r2=143887&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/GC-check.m (original)
+++ cfe/trunk/test/ARCMT/GC-check.m Sun Nov  6 12:58:23 2011
@@ -12,3 +12,8 @@
                 // expected-error {{unavailable}}
   NSAllocateCollectable(100, 0); // expected-error {{call returns pointer to GC managed memory; it will become unmanaged in ARC}}
 }
+
+ at interface I1 {
+  __strong void *gcVar; // expected-error {{GC managed memory will become unmanaged in ARC}}
+}
+ at end;

Modified: cfe/trunk/test/ARCMT/GC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/GC.h?rev=143887&r1=143886&r2=143887&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/GC.h (original)
+++ cfe/trunk/test/ARCMT/GC.h Sun Nov  6 12:58:23 2011
@@ -1,5 +1,6 @@
 
 @interface ExtInterface {
   __strong ExtInterface *myivar;
+  __strong void *gcVar;
 }
 @end





More information about the cfe-commits mailing list