aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-05-23 17:25:17 +0000
committerTed Kremenek <kremenek@apple.com>2008-05-23 17:25:17 +0000
commitca65b0241d0be198d5a61d0315d5a894f68ee494 (patch)
tree5fed8bfe19b051cb704a35bec067989822ec5701
parent1b76779233b23f8c64f2e1be9fa1f9a99ea694bd (diff)
More test cases for retain/release checker. These cases handle not flagging leaks for static variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51486 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Analysis-Apple/NSString.m38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/Analysis-Apple/NSString.m b/test/Analysis-Apple/NSString.m
index 284131fcaf..bf9d4e8e88 100644
--- a/test/Analysis-Apple/NSString.m
+++ b/test/Analysis-Apple/NSString.m
@@ -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
+