[PATCH] D60736: [Sema][ObjC] Don't warn about a block implicitly retaining self if the block is marked noescape

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 17 10:06:43 PDT 2019

rjmccall added inline comments.

Comment at: include/clang/AST/DeclBase.h:1798
+  /// innermost enclosing BlockDecl or null if there are no enclosing blocks.
+  const BlockDecl *getInnerMostBlockDecl() const {
+    const DeclContext *Ctx = this;
"innermost" is one word, so this should be `getInnermostBlockDecl`.

Comment at: lib/Sema/SemaExpr.cpp:2580
+        if (const BlockDecl *BD = CurContext->getInnerMostBlockDecl())
+          if (!getDiagnostics().isIgnored(diag::warn_implicitly_retains_self, Loc))
+            ImplicitlyRetainedSelfLocs.push_back({Loc, BD});
ahatanak wrote:
> rjmccall wrote:
> > IIRC this check can be expensive enough that it's probably not worth doing if you expect these entries to typically not result in diagnostics.
> `DiagStateMap::lookup` is doing a binary search. Is that what makes this check expensive?
Yeah.  It's not immensely expensive, but adding some entries to a vector in the fast path and then processing them later probably makes more sense.

  rC Clang



More information about the cfe-commits mailing list