[PATCH] D83997: [os_log] Improve the way we extend the lifetime of objects passed to __builtin_os_log_format

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 28 11:27:58 PDT 2020


rjmccall added a comment.

In D83997#2169745 <https://reviews.llvm.org/D83997#2169745>, @ahatanak wrote:

> The use case for this is a macro in which the call to `__builtin_os_log_format` that writes to the buffer and the call that uses the buffer appear in two different statements. For example:
>
>   __builtin_os_log_format(buf, "%@", getObj());
>   ...
>   use_buffer(buf);
>
> The object returned by the call to `getObj` has to be kept alive until `use_buffer` is called, but currently it gets destructed at the end of the full expression. I think an alternate solution would be to provide users a means to tell ARC optimizer not to move the release call for a local variable past any calls, i.e., something that is stricter than `NS_VALID_UNTIL_END_OF_SCOPE`, but that places more burden on the users.
>
> In the `os_log` macro, the result of the call to `__builtin_os_log_format` is passed directly to the call that uses the buffer, so it doesn't require any lifetime extension as you pointed out.

So are there actually any uses that take advantage of these semantics?  Because as I understand it, this builtin exists entirely to support the `os_log` macro.  If that macro doesn't need the extension semantics, let's just not do them.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83997/new/

https://reviews.llvm.org/D83997



More information about the cfe-commits mailing list