[cfe-commits] r144059 - in /cfe/trunk: lib/ARCMigrate/TransGCAttrs.cpp lib/ARCMigrate/Transforms.h test/ARCMT/GC-no-arc-runtime.m test/ARCMT/GC-no-arc-runtime.m.result
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Nov 7 18:02:39 PST 2011
Author: akirtzidis
Date: Mon Nov 7 20:02:38 2011
New Revision: 144059
URL: http://llvm.org/viewvc/llvm-project?rev=144059&view=rev
Log:
[arcmt] When we already removed a __weak, don't try to change it to __unsafe_unretained
later on, or we will end up with a redundant '__unsafe_unretained'.
Added:
cfe/trunk/test/ARCMT/GC-no-arc-runtime.m
cfe/trunk/test/ARCMT/GC-no-arc-runtime.m.result
Modified:
cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
cfe/trunk/lib/ARCMigrate/Transforms.h
Modified: cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp?rev=144059&r1=144058&r2=144059&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp Mon Nov 7 20:02:38 2011
@@ -200,6 +200,7 @@
if (TInfo->getType().getObjCLifetime() == Qualifiers::OCL_Strong) {
Transaction Trans(TA);
TA.remove(Attr.Loc);
+ MigrateCtx.RemovedAttrSet.insert(Attr.Loc.getRawEncoding());
}
}
}
@@ -233,7 +234,8 @@
if (!canApplyWeak(MigrateCtx.Pass.Ctx, Attr.ModifiedType,
/*AllowOnUnknownClass=*/true)) {
Transaction Trans(TA);
- TA.replaceText(Attr.Loc, "__weak", "__unsafe_unretained");
+ if (!MigrateCtx.RemovedAttrSet.count(Attr.Loc.getRawEncoding()))
+ TA.replaceText(Attr.Loc, "__weak", "__unsafe_unretained");
TA.clearDiagnostic(diag::err_arc_weak_no_runtime,
diag::err_arc_unsupported_weak_class,
Attr.Loc);
@@ -312,6 +314,7 @@
TA.clearDiagnostic(diag::err_objc_property_attr_mutually_exclusive, AtLoc);
TA.clearDiagnostic(diag::err_arc_inconsistent_property_ownership,
ATLs[i].second->getLocation());
+ MigrateCtx.RemovedAttrSet.insert(Loc.getRawEncoding());
}
}
@@ -347,8 +350,8 @@
clearRedundantStrongs(MigrateCtx);
errorForGCAttrsOnNonObjC(MigrateCtx);
- checkWeakGCAttrs(MigrateCtx);
checkAllProps(MigrateCtx, AllProps);
+ checkWeakGCAttrs(MigrateCtx);
}
void MigrationContext::dumpGCAttrs() {
Modified: cfe/trunk/lib/ARCMigrate/Transforms.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.h?rev=144059&r1=144058&r2=144059&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/Transforms.h (original)
+++ cfe/trunk/lib/ARCMigrate/Transforms.h Mon Nov 7 20:02:38 2011
@@ -95,6 +95,7 @@
};
std::vector<GCAttrOccurrence> GCAttrs;
llvm::DenseSet<unsigned> AttrSet;
+ llvm::DenseSet<unsigned> RemovedAttrSet;
/// \brief Set of raw '@' locations for 'assign' properties group that contain
/// GC __weak.
Added: cfe/trunk/test/ARCMT/GC-no-arc-runtime.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/GC-no-arc-runtime.m?rev=144059&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/GC-no-arc-runtime.m (added)
+++ cfe/trunk/test/ARCMT/GC-no-arc-runtime.m Mon Nov 7 20:02:38 2011
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
+// RUN: diff %t %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
+// RUN: diff %t %s.result
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = NSMakeCollectable(cft);
+}
+
+ at interface I1 {
+ __strong I1 *myivar;
+}
+ at end
+
+ at implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+-(void)finalize {
+ // finalize
+ test1(0);
+}
+ at end
+
+ at interface I2
+ at property (retain) id prop;
+ at end
+
+ at implementation I2
+ at synthesize prop;
+
+-(void)finalize {
+ self.prop = 0;
+ // finalize
+ test1(0);
+}
+ at end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+ at interface QQ {
+ __weak id s;
+ __weak QQ *q;
+}
+ at end
+
+ at interface I3
+ at property (assign) I3 *__weak pw1, *__weak pw2;
+ at property (assign) I3 *__strong ps;
+ at property (assign) I3 * pds;
+ at end
+
+ at interface I4Impl {
+ I4Impl *pds2;
+}
+ at property (assign) I4Impl *__weak pw1, *__weak pw2;
+ at property (assign) I4Impl *__strong ps;
+ at property (assign) I4Impl * pds;
+ at property (assign) I4Impl * pds2;
+ at end
+
+ at implementation I4Impl
+ at synthesize pw1, pw2, ps, pds, pds2;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = NSMakeCollectable(cft);
+}
+ at end
Added: cfe/trunk/test/ARCMT/GC-no-arc-runtime.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/GC-no-arc-runtime.m.result?rev=144059&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/GC-no-arc-runtime.m.result (added)
+++ cfe/trunk/test/ARCMT/GC-no-arc-runtime.m.result Mon Nov 7 20:02:38 2011
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
+// RUN: diff %t %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
+// RUN: diff %t %s.result
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = CFBridgingRelease(cft);
+}
+
+ at interface I1 {
+ I1 *myivar;
+}
+ at end
+
+ at implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+ at end
+
+ at interface I2
+ at property id prop;
+ at end
+
+ at implementation I2
+ at synthesize prop;
+
+-(void)dealloc {
+ // finalize
+ test1(0);
+}
+ at end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+ at interface QQ {
+ __unsafe_unretained id s;
+ __unsafe_unretained QQ *q;
+}
+ at end
+
+ at interface I3
+ at property (unsafe_unretained) I3 * pw1, * pw2;
+ at property (strong) I3 * ps;
+ at property (assign) I3 * pds;
+ at end
+
+ at interface I4Impl {
+ I4Impl *pds2;
+}
+ at property (unsafe_unretained) I4Impl * pw1, * pw2;
+ at property I4Impl * ps;
+ at property I4Impl * pds;
+ at property I4Impl * pds2;
+ at end
+
+ at implementation I4Impl
+ at synthesize pw1, pw2, ps, pds, pds2;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = CFBridgingRelease(cft);
+}
+ at end
More information about the cfe-commits
mailing list