Fix a bug found by Thomas Clement where 'return [[[NSString alloc] init] autorelease]' would emit a false 'too many overreleases' error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71432 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m
index 702551b..d5a7870 100644
--- a/test/Analysis/NSString.m
+++ b/test/Analysis/NSString.m
@@ -36,6 +36,7 @@
- (BOOL)isEqual:(id)object;
- (oneway void)release;
- (id)retain;
+- (id)autorelease;
@end
@protocol NSCopying
- (id)copyWithZone:(NSZone *)zone;
@@ -173,6 +174,17 @@
CFRelease(ref); // expected-warning{{Reference-counted object is used after it is released}}
}
+// Test regular use of -autorelease
+@interface TestAutorelease
+-(NSString*) getString;
+@end
+@implementation TestAutorelease
+-(NSString*) getString {
+ NSString *str = [[NSString alloc] init];
+ return [str autorelease]; // no-warning
+}
+@end
+
@interface C1 : NSObject {}
- (NSString*) getShared;
+ (C1*) sharedInstance;