summaryrefslogtreecommitdiffstats
path: root/lib/ARCMigrate
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-08 02:02:38 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-08 02:02:38 +0000
commit7cfd7fe020144afe61ffe4de6c43c10340c415a7 (patch)
tree8a0277362e5cfb6d7a82d05976adfbdd095345d7 /lib/ARCMigrate
parent1aa1721f14f2162811f5393dbd84e01eadc2c963 (diff)
[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'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ARCMigrate')
-rw-r--r--lib/ARCMigrate/TransGCAttrs.cpp7
-rw-r--r--lib/ARCMigrate/Transforms.h1
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/ARCMigrate/TransGCAttrs.cpp b/lib/ARCMigrate/TransGCAttrs.cpp
index 8f3926fbbc..dc22375048 100644
--- a/lib/ARCMigrate/TransGCAttrs.cpp
+++ b/lib/ARCMigrate/TransGCAttrs.cpp
@@ -200,6 +200,7 @@ static void clearRedundantStrongs(MigrationContext &MigrateCtx) {
if (TInfo->getType().getObjCLifetime() == Qualifiers::OCL_Strong) {
Transaction Trans(TA);
TA.remove(Attr.Loc);
+ MigrateCtx.RemovedAttrSet.insert(Attr.Loc.getRawEncoding());
}
}
}
@@ -233,7 +234,8 @@ static void checkWeakGCAttrs(MigrationContext &MigrateCtx) {
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 @@ static void checkAllAtProps(MigrationContext &MigrateCtx,
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 @@ void GCAttrsTraverser::traverseTU(MigrationContext &MigrateCtx) {
clearRedundantStrongs(MigrateCtx);
errorForGCAttrsOnNonObjC(MigrateCtx);
- checkWeakGCAttrs(MigrateCtx);
checkAllProps(MigrateCtx, AllProps);
+ checkWeakGCAttrs(MigrateCtx);
}
void MigrationContext::dumpGCAttrs() {
diff --git a/lib/ARCMigrate/Transforms.h b/lib/ARCMigrate/Transforms.h
index 49fd0f726d..8c09a4757c 100644
--- a/lib/ARCMigrate/Transforms.h
+++ b/lib/ARCMigrate/Transforms.h
@@ -95,6 +95,7 @@ public:
};
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.