aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-03-19 19:50:58 +0000
committerTed Kremenek <kremenek@apple.com>2009-03-19 19:50:58 +0000
commitc505d4f1568796f29ec9f1c57d861b54a088da1f (patch)
treefa1547c24db77f428bb0f8ab5eacd883731ee357
parentf2a17b13c2c4b3847afa949397799624104faa3a (diff)
Add test cases for PR 3820.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67327 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Analysis/retain-release.m26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m
index c6a05c0031..50a809c36a 100644
--- a/test/Analysis/retain-release.m
+++ b/test/Analysis/retain-release.m
@@ -69,6 +69,8 @@ typedef struct _NSZone NSZone;
- (const char *)UTF8String;
- (id)initWithUTF8String:(const char *)nullTerminatedCString;
+ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+- (id)init;
+- (void)dealloc;
@end extern NSString * const NSCurrentLocaleDidChangeNotification ;
@protocol NSLocking - (void)lock;
@end extern NSString * const NSUndoManagerCheckpointNotification;
@@ -334,3 +336,27 @@ static void rdar_6659160(char *inkind, char *inname)
}
@end
+// PR 3820 - Reason about calls to -dealloc
+void pr3820_DeallocInsteadOfRelease(void)
+{
+ id foo = [[NSString alloc] init]; // no-warning
+ [foo dealloc];
+ // foo is not leaked, since it has been deallocated.
+}
+
+void pr3820_ReleaseAfterDealloc(void)
+{
+ id foo = [[NSString alloc] init];
+ [foo dealloc];
+ [foo release]; // expected-warning{{used after it is release}}
+ // NSInternalInconsistencyException: message sent to deallocated object
+}
+
+void pr3820_DeallocAfterRelease(void)
+{
+ NSLog(@"\n\n[%s]", __FUNCTION__);
+ id foo = [[NSString alloc] init];
+ [foo release];
+ [foo dealloc]; // expected-warning{{used after it is released}}
+ // message sent to released object
+}