[cfe-commits] r156999 - in /cfe/trunk: lib/ARCMigrate/TransRetainReleaseDealloc.cpp test/ARCMT/checking.m

John McCall rjmccall at apple.com
Sat May 19 00:21:57 PDT 2012


On May 17, 2012, at 11:16 AM, Argyrios Kyrtzidis wrote:
> Author: akirtzidis
> Date: Thu May 17 13:16:05 2012
> New Revision: 156999
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=156999&view=rev
> Log:
> [arcmt] Remove the "it is not safe to remove an unused 'autorelease' message" ARC
> migration error.
> 
> This is more trouble that it is worth; autoreleasing a value without holding on it
> is a valid use-case, we should not "punish" correct code for the minority of
> broken/fragile programs that depend on the behavior of  -autorelease.
> 
> rdar://9914061

I wish you'd asked me about this.  The user in question is doing an
autorelease to avoid a temporary during an assignment operation.
That seems like a perfectly reasonable idiom to recognize and so
delete the autorelease.

However, I am not comfortable with deleting arbitrary instances of
  [foo autorelease];
because there are some common patterns in GUI programming
where this is intentionally done to cause something to be deleted "later".
For example, if -[Widget handleEvent] calls -[Controller nextPage] and
the latter wants to destroy the widget, it might intentionally autorelease
instead of releasing so that self won't disappear out from under
-[Widget handleEvent].

Turning that into "delete this now" is just papering over problems
that the user really ought to deal with during the migration process.

John.



More information about the cfe-commits mailing list