From: Argyrios Kyrtzidis Date: Sat, 25 Feb 2012 01:57:42 +0000 (+0000) Subject: [arcmt] GC migrator: don't try to remove redundant __strong, it does X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63787f0343ab3546a5346a833e2f7485779f17e2;p=clang [arcmt] GC migrator: don't try to remove redundant __strong, it does more harm than good. Fixes rdar://10522805&10521433 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151424 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ARCMigrate/TransGCAttrs.cpp b/lib/ARCMigrate/TransGCAttrs.cpp index fa62b36208..de710abb5d 100644 --- a/lib/ARCMigrate/TransGCAttrs.cpp +++ b/lib/ARCMigrate/TransGCAttrs.cpp @@ -183,30 +183,6 @@ public: } // anonymous namespace -static void clearRedundantStrongs(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.Kind == MigrationContext::GCAttrOccurrence::Strong && - Attr.FullyMigratable && Attr.Dcl) { - TypeSourceInfo *TInfo = 0; - if (DeclaratorDecl *DD = dyn_cast(Attr.Dcl)) - TInfo = DD->getTypeSourceInfo(); - else if (ObjCPropertyDecl *PD = dyn_cast(Attr.Dcl)) - TInfo = PD->getTypeSourceInfo(); - if (!TInfo) - continue; - - if (TInfo->getType().getObjCLifetime() == Qualifiers::OCL_Strong) { - Transaction Trans(TA); - TA.remove(Attr.Loc); - MigrateCtx.RemovedAttrSet.insert(Attr.Loc.getRawEncoding()); - } - } - } -} - static void errorForGCAttrsOnNonObjC(MigrationContext &MigrateCtx) { TransformActions &TA = MigrateCtx.Pass.TA; @@ -354,7 +330,6 @@ void GCAttrsTraverser::traverseTU(MigrationContext &MigrateCtx) { GCAttrsCollector(MigrateCtx, AllProps).TraverseDecl( MigrateCtx.Pass.Ctx.getTranslationUnitDecl()); - clearRedundantStrongs(MigrateCtx); errorForGCAttrsOnNonObjC(MigrateCtx); checkAllProps(MigrateCtx, AllProps); checkWeakGCAttrs(MigrateCtx); diff --git a/test/ARCMT/GC-no-arc-runtime.m b/test/ARCMT/GC-no-arc-runtime.m index ab9d6a4ae5..f0699927ed 100644 --- a/test/ARCMT/GC-no-arc-runtime.m +++ b/test/ARCMT/GC-no-arc-runtime.m @@ -12,9 +12,7 @@ void test1(CFTypeRef *cft) { id x = NSMakeCollectable(cft); } -@interface I1 { - __strong I1 *myivar; -} +@interface I1 @end @implementation I1 diff --git a/test/ARCMT/GC-no-arc-runtime.m.result b/test/ARCMT/GC-no-arc-runtime.m.result index 983a5b1742..f55ca38070 100644 --- a/test/ARCMT/GC-no-arc-runtime.m.result +++ b/test/ARCMT/GC-no-arc-runtime.m.result @@ -12,9 +12,7 @@ void test1(CFTypeRef *cft) { id x = CFBridgingRelease(cft); } -@interface I1 { - I1 *myivar; -} +@interface I1 @end @implementation I1 diff --git a/test/ARCMT/GC-no-finalize-removal.m b/test/ARCMT/GC-no-finalize-removal.m index d9739376f2..14e8602446 100644 --- a/test/ARCMT/GC-no-finalize-removal.m +++ b/test/ARCMT/GC-no-finalize-removal.m @@ -12,9 +12,7 @@ void test1(CFTypeRef *cft) { id x = NSMakeCollectable(cft); } -@interface I1 { - __strong I1 *myivar; -} +@interface I1 @end @implementation I1 diff --git a/test/ARCMT/GC-no-finalize-removal.m.result b/test/ARCMT/GC-no-finalize-removal.m.result index 38aabc32ae..ea14873ec3 100644 --- a/test/ARCMT/GC-no-finalize-removal.m.result +++ b/test/ARCMT/GC-no-finalize-removal.m.result @@ -12,9 +12,7 @@ void test1(CFTypeRef *cft) { id x = CFBridgingRelease(cft); } -@interface I1 { - I1 *myivar; -} +@interface I1 @end @implementation I1 diff --git a/test/ARCMT/GC.m b/test/ARCMT/GC.m index f241e43008..eebbaf6854 100644 --- a/test/ARCMT/GC.m +++ b/test/ARCMT/GC.m @@ -12,9 +12,7 @@ void test1(CFTypeRef *cft) { id x = NSMakeCollectable(cft); } -@interface I1 { - __strong I1 *myivar; -} +@interface I1 @end @implementation I1 @@ -90,3 +88,8 @@ __attribute__((objc_arc_weak_reference_unavailable)) @implementation rdar10532449 @synthesize assign_prop, strong_readonly_prop, weak_prop; @end + +void test2(id p, __strong I1 *ap[]) { + for (__strong I1 *specRule in p) { + } +} diff --git a/test/ARCMT/GC.m.result b/test/ARCMT/GC.m.result index f9e954af5a..c2c523f77e 100644 --- a/test/ARCMT/GC.m.result +++ b/test/ARCMT/GC.m.result @@ -12,9 +12,7 @@ void test1(CFTypeRef *cft) { id x = CFBridgingRelease(cft); } -@interface I1 { - I1 *myivar; -} +@interface I1 @end @implementation I1 @@ -85,3 +83,8 @@ __attribute__((objc_arc_weak_reference_unavailable)) @implementation rdar10532449 @synthesize assign_prop, strong_readonly_prop, weak_prop; @end + +void test2(id p, __strong I1 *ap[]) { + for (__strong I1 *specRule in p) { + } +}