[PATCH] D49119: [Sema][ObjC] Issue a warning when a method declared in a protocol is non-escaping but the corresponding method in the implementation is escaping.

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 27 15:47:16 PDT 2018


ahatanak added a comment.

Thanks, I'll update the patch and commit it today.

In https://reviews.llvm.org/D49119#1176139, @vsapsai wrote:

> In https://reviews.llvm.org/D49119#1176047, @ahatanak wrote:
>
> > In https://reviews.llvm.org/D49119#1164285, @vsapsai wrote:
> >
> > > Also I had a few ideas for tests when the warning isn't required and it is absent. But I'm not sure they are actually valuable. If you are interested, we can discuss it in more details.
> >
> >
> > Could you elaborate on what kind of tests you have in mind?
>
>
>
>
> - declaring `noescape` on implementation when nothing like that was mentioned in interface or protocols;


Maybe we should consider this, but I don't think this is incorrect functionally. If you pass an object to such methods, clang's IRGen will just emit the unoptimized code that is emitted for calls to functions/methods taking escaping parameters (e.g., no 'nocapture' on parameters, no stack block optimization implemented in r337580). The opposite case (non-escaping interface and escaping implementation) is incorrect and can cause problems, so we need some diagnostics.

> - have class method and instance method with the same name, only one of them is `noescape`, test that we don't show spurious warning in this case;

I can add a test case for this.

> - try selector names that look similar but are different, like `-foo`, `-foo:`, `-foo::` This test suggestion isn't really related to `noescape`, I just got carried away.




Repository:
  rC Clang

https://reviews.llvm.org/D49119





More information about the cfe-commits mailing list