]> granicus.if.org Git - clang/commitdiff
More test cases for retain/release checker. These cases handle not flagging leaks...
authorTed Kremenek <kremenek@apple.com>
Fri, 23 May 2008 17:25:17 +0000 (17:25 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 23 May 2008 17:25:17 +0000 (17:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51486 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis-Apple/NSString.m

index 284131fcaf419e9957b85137bbff27825f47e31d..bf9d4e8e882916aea0ea68d84b238ad6c2e66e74 100644 (file)
@@ -60,3 +60,41 @@ void f9() {
   [s release];
   [q release]; // expected-warning {{used after it is released}}
 }
+
+NSString* f10() {
+  
+  static NSString* s = nil;
+  
+  if (!s) s = [[NSString alloc] init];
+    
+  return s; // no-warning
+}
+
+@interface C1 : NSObject {}
+
+- (NSString*) getShared;
++ (C1*) sharedInstance;
+
+@end
+
+@implementation C1 : NSObject {}
+
+- (NSString*) getShared {
+  
+  static NSString* s = nil;
+  
+  if (!s) s = [[NSString alloc] init];
+    
+  return s; // no-warning  
+}
+
++ (C1 *)sharedInstance {
+  static C1 *sharedInstance = nil;
+  if (!sharedInstance) {
+    sharedInstance = [[C1 alloc] init];
+  }
+  return sharedInstance; // no-warning
+}
+
+@end
+