diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-06 18:58:23 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-06 18:58:23 +0000 |
commit | 280b4ada965f89607684446e826d830f0b8a7864 (patch) | |
tree | 6d8cee8bcfa73c954115abdf5d1152b72d8cb4c7 | |
parent | 17ac3197941b9f135424dfe3900577a04407c5c2 (diff) |
[arcmt] In GC, error for __strong/__weak on non-objc pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143887 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/ARCMigrate/TransGCAttrs.cpp | 18 | ||||
-rw-r--r-- | test/ARCMT/GC-check.m | 5 | ||||
-rw-r--r-- | test/ARCMT/GC.h | 1 |
3 files changed, 24 insertions, 0 deletions
diff --git a/lib/ARCMigrate/TransGCAttrs.cpp b/lib/ARCMigrate/TransGCAttrs.cpp index a85cad4d44..79dc0538b6 100644 --- a/lib/ARCMigrate/TransGCAttrs.cpp +++ b/lib/ARCMigrate/TransGCAttrs.cpp @@ -186,10 +186,28 @@ static void clearRedundantStrongs(MigrationContext &MigrateCtx) { } } +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() { diff --git a/test/ARCMT/GC-check.m b/test/ARCMT/GC-check.m index f71787ce02..9864354228 100644 --- a/test/ARCMT/GC-check.m +++ b/test/ARCMT/GC-check.m @@ -12,3 +12,8 @@ void test1(CFTypeRef *cft) { // expected-error {{unavailable}} NSAllocateCollectable(100, 0); // expected-error {{call returns pointer to GC managed memory; it will become unmanaged in ARC}} } + +@interface I1 { + __strong void *gcVar; // expected-error {{GC managed memory will become unmanaged in ARC}} +} +@end; diff --git a/test/ARCMT/GC.h b/test/ARCMT/GC.h index 6202e478c3..4301baf272 100644 --- a/test/ARCMT/GC.h +++ b/test/ARCMT/GC.h @@ -1,5 +1,6 @@ @interface ExtInterface { __strong ExtInterface *myivar; + __strong void *gcVar; } @end |