diff options
author | Brian Kelley <bkelley@microsoft.com> | 2017-03-29 17:55:11 +0000 |
---|---|---|
committer | Brian Kelley <bkelley@microsoft.com> | 2017-03-29 17:55:11 +0000 |
commit | f884a84581cc04739b945fa4c6068bc1a233f718 (patch) | |
tree | 5344d92c9cd8a183c0eb940ba9815740fae6f813 /lib/Sema/SemaPseudoObject.cpp | |
parent | 16b7f511e8cd5f5ea6c57a11a238f4aa56d33d7f (diff) |
[Objective-C] Fix "repeated use of weak" warning with -fobjc-weak
Summary: -Warc-repeated-use-of-weak should produce the same warnings with -fobjc-weak as it does with -objc-arc. Also check for ObjCWeak along with ObjCAutoRefCount when recording the use of an evaluated weak variable. Add a -fobjc-weak run to the existing arc-repeated-weak test case and adapt it slightly to work in both modes.
Reviewers: rsmith, doug.gregor, jordan_rose, rjmccall
Reviewed By: rjmccall
Subscribers: arphaman, rjmccall, cfe-commits
Differential Revision: https://reviews.llvm.org/D31005
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaPseudoObject.cpp')
-rw-r--r-- | lib/Sema/SemaPseudoObject.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp index b740540dca..05c593b075 100644 --- a/lib/Sema/SemaPseudoObject.cpp +++ b/lib/Sema/SemaPseudoObject.cpp @@ -842,12 +842,10 @@ ExprResult ObjCPropertyOpBuilder::buildRValueOperation(Expr *op) { result = S.ImpCastExprToType(result.get(), propType, CK_BitCast); } } - if (S.getLangOpts().ObjCAutoRefCount) { - Qualifiers::ObjCLifetime LT = propType.getObjCLifetime(); - if (LT == Qualifiers::OCL_Weak) - if (!S.Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, RefExpr->getLocation())) - S.getCurFunction()->markSafeWeakUse(RefExpr); - } + if (propType.getObjCLifetime() == Qualifiers::OCL_Weak && + !S.Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, + RefExpr->getLocation())) + S.getCurFunction()->markSafeWeakUse(RefExpr); } return result; @@ -963,11 +961,11 @@ ObjCPropertyOpBuilder::buildIncDecOperation(Scope *Sc, SourceLocation opcLoc, } ExprResult ObjCPropertyOpBuilder::complete(Expr *SyntacticForm) { - if (S.getLangOpts().ObjCAutoRefCount && isWeakProperty() && + if (isWeakProperty() && !S.Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, SyntacticForm->getLocStart())) - S.recordUseOfEvaluatedWeak(SyntacticRefExpr, - SyntacticRefExpr->isMessagingGetter()); + S.recordUseOfEvaluatedWeak(SyntacticRefExpr, + SyntacticRefExpr->isMessagingGetter()); return PseudoOpBuilder::complete(SyntacticForm); } |