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

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 23 09:20:42 PDT 2020


ahatanak added a comment.

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.


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