[LLVMbugs] [Bug 11187] New: Add checks that completionHandlers are called

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 19 18:47:00 PDT 2011


           Summary: Add checks that completionHandlers are called
           Product: clang
           Version: 2.8
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: tjw at me.com
                CC: llvmbugs at cs.uiuc.edu

Several Cocoa APIs now take completion handler blocks and failure to call those
completion handlers results in hard to debug errors and deadlocks.

clang-sa could have an annotation on block arguments (say
"__attribute__((must_call))" for the sake of argument) and it could
automatically apply that if the block argument or method name fragment is
called 'completionHandler'.

For example:

- (void)doSomethingAsync:(void (^)(void))completionHandler;
    if (!thing1Works) {
        if (completionHandler)
            completionHandler(); // OK

    return; // diagnostic since the completionHandler wasn't called

This would need to handle the pattern where the completionHandler is destined
to be invoked on another queue:

- (void)doSomethingAsync:(void (^)(NSError *errorOrNil))completionHandler;
    NSError *error;

    ... do some stuff ...

    if (completionHandler) {
        [[NSOperationQueue mainQueue] addOperationWithBlock:^{

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list