<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 --- - Let developers annotate, and the analyzer catch, threading requirements on function/method calls"
   href="http://llvm.org/bugs/show_bug.cgi?id=15995">15995</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Let developers annotate, and the analyzer catch, threading requirements on function/method calls
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>kremenek@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>iamleeg@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>Summary:

some frameworks, notably AppKit and UIKit, require particular methods to be
called on particular threads, but contain no checks for this requirement.
Please could clang give the ability to annotate functions with thread
requirements, and the analyzer check for simple transgressions?

Steps to reproduce:

I imagine being able to write code like this:

@interface UIView
//…
- (void)removeFromSuperview __attribute__((main_thread_only));
@end

and calling that like this:

dispatch_async(my_non_main_queue, ^{[someLabel removeFromSuperview];}]);

Expected results:

running scan-build on the above code should emit a message that the method with
a main_thread_only attribute is dispatched to a queue that doesn't schedule
work on the main thread.

Actual results:

This is an enhancement request, the expected functionality does not yet exist.

Regression: none.

Notes:

This analyzer rule could catch use of main-thread code on private dispatch
queues, global dispatch queues and non-main NSOperationQueues, in addition to
non-main threads created via pthread_create() or (ideally, though with
difficulty) +[NSThread detachNewThread…].

While ideally the check for which thread an object needs to be used on would be
either handled by that object or part of the object's contract with its
callers, there are performance implications on including such tests at runtime.
There are also benefits to detecting the problems at build time. Both of these
reasons motivate this request for the analyzer to detect such issues.</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>