diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2019-04-17 23:14:44 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2019-04-17 23:14:44 +0000 |
commit | 60c28aa5e61234203c655d857fed2e1984905f91 (patch) | |
tree | 816dd61c42e4957dad15f2dfdf7a57be5deaf98e /lib/Sema/SemaExpr.cpp | |
parent | 3f087b48e218e54bf8bce401db003fc98bc8a886 (diff) | |
download | clang-60c28aa5e61234203c655d857fed2e1984905f91.tar.gz |
[Sema][ObjC] Don't warn about an implicitly retained self if the
retaining block and all of the enclosing blocks are non-escaping.
If the block implicitly retaining self doesn't escape, there is no risk
of creating retain cycles, so clang shouldn't diagnose it and force
users to add self-> to silence the diagnostic.
Also, fix a bug where clang was failing to diagnose an implicitly
retained self inside a c++ lambda nested inside a block.
rdar://problem/25059955
Differential Revision: https://reviews.llvm.org/D60736
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@358624 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index ef39092821..e64eeecb2a 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2575,11 +2575,9 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc)) getCurFunction()->recordUseOfWeak(Result); } - if (getLangOpts().ObjCAutoRefCount) { - if (CurContext->isClosure()) - Diag(Loc, diag::warn_implicitly_retains_self) - << FixItHint::CreateInsertion(Loc, "self->"); - } + if (getLangOpts().ObjCAutoRefCount) + if (const BlockDecl *BD = CurContext->getInnermostBlockDecl()) + ImplicitlyRetainedSelfLocs.push_back({Loc, BD}); return Result; } |