Bug 140215 - Annotate properties that start with "new" so they'll work under ARC
Summary: Annotate properties that start with "new" so they'll work under ARC
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-07 14:46 PST by Anders Carlsson
Modified: 2015-01-07 20:45 PST (History)
1 user (show)

See Also:


Attachments
Patch (2.38 KB, patch)
2015-01-07 14:47 PST, Anders Carlsson
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anders Carlsson 2015-01-07 14:46:08 PST
Annotate properties that start with "new" so they'll work under ARC
Comment 1 Anders Carlsson 2015-01-07 14:47:53 PST
Created attachment 244206 [details]
Patch
Comment 2 Geoffrey Garen 2015-01-07 14:58:17 PST
Comment on attachment 244206 [details]
Patch

r=me
Comment 3 Geoffrey Garen 2015-01-07 14:58:35 PST
Does this require an update to some bindings test expectations or a new bindings test?
Comment 4 Anders Carlsson 2015-01-07 14:59:42 PST
Committed r178057: <http://trac.webkit.org/changeset/178057>
Comment 5 Darin Adler 2015-01-07 20:45:56 PST
Comment on attachment 244206 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=244206&action=review

> Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm:899
> +                my $needsReturnsRetainedAnnotation = $attributeName =~ /new([A-Z].*)?/;

http://clang.llvm.org/docs/AutomaticReferenceCounting.html#method-families says that we also need to check for alloc, copy, mutableCopy, and new. And maybe even init. I also was considering whether __attribute__((objc_method_family(none))) might not be better than NS_RETURNS_NOT_RETAINED, but I guess not.

Given that documentation, I’m thinking this regular expression should be:

    /_*(alloc|copy|mutableCopy|new)([^a-z].*)?/

That wouldn’t address the init family, but it would cover the copy cases, which I think could easily happen in practice.