> On Jan 12, 2023, at 1:27 PM, Darin Adler <da...@apple.com> wrote:
> 
>> On Jan 12, 2023, at 3:35 PM, Ryosuke Niwa via webkit-dev 
>> <webkit-dev@lists.webkit.org> wrote:
>> 
>>> On Jan 12, 2023, at 6:13 AM, Darin Adler <da...@apple.com> wrote:
>>> 
>>>> On Jan 12, 2023, at 12:21 AM, Ryosuke Niwa via webkit-dev 
>>>> <webkit-dev@lists.webkit.org> wrote:
>>>> 
>>>> assuming every local variable / variable in stack is stored in a smart 
>>>> pointer, function arguments are safe to be raw pointers / references via 
>>>> transitive property
>>> 
>>> What about the case where the function argument is the return value from 
>>> another function?
>> 
>> In those cases, the value should be stored in a local variable using a smart 
>> pointer first.
>> 
>> So… instead of:
>> foo(bar());
>> 
>> do:
>> foo(RefPtr { bar() }.get());
> 
> This seems impractical. How will I remember to do this?

The smart pointer analysis tool I've been working with the clang team should be 
able to tell you that once it becomes available. Until then, we probably need 
to rely on reviewers to notice these patterns.

One alternative is to make bar() return RefPtr although that would be a bit 
heavy handed in the case of trivial function calls like this: 
document().frame()->ownerElement()

- R. Niwa

_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to