<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Attribute for "arc-retain-cycles" check in addition to "add" and "set" method selector prefix convention"
   href="http://llvm.org/bugs/show_bug.cgi?id=17669">17669</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Attribute for "arc-retain-cycles" check in addition to "add" and "set" method selector prefix convention
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>fortinmike@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This enhancement request pertains to Objective-C warnings generated by clang.

I am implementing a few methods in a library that take block arguments and
store them for later, repeated execution. However, those methods do not benefit
from the "arc-retain-cycles" warning because their signature doesn't begin with
"add" nor "set"; it’s pretty easy to create a retain cycle by accident,
particularly for novice Objective-C devs. I would like to annotate the methods
I know can lead to cycles for inclusion in this check to save others (and
myself) from introducing leaks in the future.

I’m proposing adding an Objective-C-specific attribute (if that’s the
appropriate construct) to indicate that a method’s usages should be checked for
potential retain cycles without requiring the method to begin with “add” or
“set". Something like:

- (void)doSomethingWithObject:(id)anObject andBlock:(void (^)())aBlock
__attribute__((check_retain_cycles));

In addition, it would probably be nice to offer the complementary ability to
exclude some “add” and “set”-prefixed methods from the retain cycle check if we
know it’s not relevant in a specific case, like the NSOperationQueue
“addOperationWithBlock” exclusion that’s currently hard-coded in the
isSetterLikeSelector() function (SemaChecking.cpp:6620) but in a dynamic way
using an attribute:

- (void)addOperationWithBlock:(void (^)(void))block
__attribute__((dont_check_retain_cycles));</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>