[arcmt] Before applying '__weak' check whether the objc class is annotated with objc_arc_weak_reference_unavailable
or is in a list of classes not supporting 'weak'.
rdar://9489367.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135002 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ARCMigrate/TransProperties.cpp b/lib/ARCMigrate/TransProperties.cpp
index 0efc4c0..82ef717 100644
--- a/lib/ARCMigrate/TransProperties.cpp
+++ b/lib/ARCMigrate/TransProperties.cpp
@@ -112,7 +112,7 @@
}
void applyWeak(PropData &prop) {
- assert(Pass.Ctx.getLangOptions().ObjCRuntimeHasWeak);
+ assert(canApplyWeak(Pass.Ctx, prop.IvarD->getType()));
Transaction Trans(Pass.TA);
Pass.TA.insert(prop.IvarD->getLocation(), "__weak ");
@@ -157,7 +157,7 @@
// There is a "error: existing ivar for assign property must be
// __unsafe_unretained"; fix it.
- if (!Pass.Ctx.getLangOptions().ObjCRuntimeHasWeak) {
+ if (!canApplyWeak(Pass.Ctx, ivarD->getType())) {
// We will just add __unsafe_unretained to the ivar.
Transaction Trans(Pass.TA);
Pass.TA.insert(ivarD->getLocation(), "__unsafe_unretained ");