title: Objective-C Singletons and LLVM/clang leak warnings
body: <p>I'm using the singleton pattern in several places in an application, and I'm getting memory leak errors from <code>clang</code> when analyzing the code.</p>
  
  <pre><code>static MyClass *_sharedMyClass;
  + (MyClass *)sharedMyClass {
    @synchronized(self) {
      if (_sharedMyClass == nil)
        [[self alloc] init];
    }
    return _sharedMyClass;
  }
  
  // clang error: Object allocated on line 5 is no longer referenced after this point and has a retain count of +1 (object leaked)
  </code></pre>
  
  <p>I'm using these settings for <code>scan-build</code>:</p>
  
  <p><code>scan-build -v -v -v -V -k xcodebuild</code></p>
  
  <p>I'm fairly certain that the code in the singleton is just fine - after all, it's the same code referenced here on Stack Overflow as well as in Apple's documentation - but I would like to get the memory leak warning sorted out so my scan-build returns success.</p>