[cfe-dev] CodeGen help for a new feature in ObjC

John McCall rjmccall at apple.com
Tue Dec 20 10:52:45 PST 2011


On Dec 20, 2011, at 6:58 AM, Remy Demarest wrote:
> So, my actual problem is in CodeGen. I've god the weak capture itself working, the compiler generates the objc_loadWeak() to store the captured variable in the block structure as a weak. What I'm missing is the retain and release inside the code and there I'm not sure how to work it out.

This is because you're trying to generalize from straight-line code, where the scope and CFG concerns are trivial.  In general, it is not possible to statically decide which use is the first use, and it is not possible to even dynamically decide which use is the last use.  For example, when do you want the retains and releases to happen in this code?

  ^{ __weak_capture(self); for (…) { if (...) [self blah]; }

John.



More information about the cfe-dev mailing list