[cfe-commits] r51486 - /cfe/trunk/test/Analysis-Apple/NSString.m
Ted Kremenek
kremenek at apple.com
Fri May 23 10:25:18 PDT 2008
Author: kremenek
Date: Fri May 23 12:25:17 2008
New Revision: 51486
URL: http://llvm.org/viewvc/llvm-project?rev=51486&view=rev
Log:
More test cases for retain/release checker. These cases handle not flagging leaks for static variables.
Modified:
cfe/trunk/test/Analysis-Apple/NSString.m
Modified: cfe/trunk/test/Analysis-Apple/NSString.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis-Apple/NSString.m?rev=51486&r1=51485&r2=51486&view=diff
==============================================================================
--- cfe/trunk/test/Analysis-Apple/NSString.m (original)
+++ cfe/trunk/test/Analysis-Apple/NSString.m Fri May 23 12:25:17 2008
@@ -60,3 +60,41 @@
[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
+}
+
+ at interface C1 : NSObject {}
+
+- (NSString*) getShared;
++ (C1*) sharedInstance;
+
+ at end
+
+ at 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
+}
+
+ at end
+
More information about the cfe-commits
mailing list