summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/self-init.m
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-03-05 18:58:25 +0000
committerAnna Zaks <ganna@apple.com>2012-03-05 18:58:25 +0000
commit53a0b6c161e1d17b37c3ad51d885bad7efba764a (patch)
treead4c8a9ce3da720798ce4150907f5306ce26b660 /clang/test/Analysis/self-init.m
parent641e95de867e1f94763430500a0ec0d3e0e095d4 (diff)
downloadbcm5719-llvm-53a0b6c161e1d17b37c3ad51d885bad7efba764a.tar.gz
bcm5719-llvm-53a0b6c161e1d17b37c3ad51d885bad7efba764a.zip
[analyzer] False positive in SelfInit - teach the checker about method
calls with self as a parameter. llvm-svn: 152039
Diffstat (limited to 'clang/test/Analysis/self-init.m')
-rw-r--r--clang/test/Analysis/self-init.m29
1 files changed, 25 insertions, 4 deletions
diff --git a/clang/test/Analysis/self-init.m b/clang/test/Analysis/self-init.m
index eaa8fd46f19..3db42e9cf5a 100644
--- a/clang/test/Analysis/self-init.m
+++ b/clang/test/Analysis/self-init.m
@@ -1,8 +1,8 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit %s -verify
@class NSZone, NSCoder;
-@protocol NSObject
-@end
+@protocol NSObject- (id)self;
+@end
@protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
@end
@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
@@ -22,9 +22,14 @@
//#import "Foundation/NSObject.h"
typedef unsigned NSUInteger;
-typedef int NSInteger;
+typedef long NSInteger;
+
+@interface NSInvocation : NSObject {}
+- (void)getArgument:(void *)argumentLocation atIndex:(NSInteger)idx;
+- (void)setArgument:(void *)argumentLocation atIndex:(NSInteger)idx;
+@end
-@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@class NSMethodSignature, NSCoder, NSString, NSEnumerator;
@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
- (NSUInteger)length;
+ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
@@ -180,3 +185,19 @@ static id _commonInit(MyObj *self) {
- (id)init { return self; }
@end
+
+
+// Test for radar://10973514 : self should not be invalidated by a method call.
+@interface Test : NSObject {
+ NSInvocation *invocation_;
+}
+@end
+@implementation Test
+-(id) initWithTarget:(id) rec selector:(SEL) cb {
+ if (self=[super init]) {
+ [invocation_ setArgument:&self atIndex:2];
+ }
+ return self;
+}
+@end
+
OpenPOWER on IntegriCloud