diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-08-07 21:13:23 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-08-07 21:13:23 +0000 |
commit | 35ffcf3c2a054ee124fe8d47152c5d1bcdf86261 (patch) | |
tree | e2fe409aa13d84b9d07b0db4d5aef2e8f52cedf8 /test/Analysis/unused-ivars.m | |
parent | 0b2dd776318e612c682d32e1f4ca70f7b223c05e (diff) |
Fix: <rdar://problem/7075531> static analyzer wrongly detects unused ivars used in blocks
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78409 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/unused-ivars.m')
-rw-r--r-- | test/Analysis/unused-ivars.m | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/test/Analysis/unused-ivars.m b/test/Analysis/unused-ivars.m index 632b395c3e..aacd44e7e6 100644 --- a/test/Analysis/unused-ivars.m +++ b/test/Analysis/unused-ivars.m @@ -1,10 +1,45 @@ -// RUN: clang-cc -analyze -warn-objc-unused-ivars %s -verify +// RUN: clang-cc -triple x86_64-apple-darwin10 -analyze -warn-objc-unused-ivars %s -verify -@interface A -{ - @private int x; // expected-warning {{Instance variable 'x' in class 'A' is never used}} +//===--- BEGIN: Delta-debugging reduced headers. --------------------------===// + +@protocol NSObject +- (id)retain; +- (oneway void)release; +@end +@interface NSObject <NSObject> {} +- (id)init; ++ (id)alloc; +@end + +//===--- END: Delta-debugging reduced headers. ----------------------------===// + +// This test case tests the basic functionality of the unused ivar test. +@interface TestA { +@private + int x; // expected-warning {{Instance variable 'x' in class 'TestA' is never used}} } @end +@implementation TestA @end -@implementation A @end +// This test case tests whether the unused ivar check handles blocks that +// reference an instance variable. (<rdar://problem/7075531>) +@interface TestB : NSObject { +@private + id _ivar; // no-warning +} +@property (readwrite,retain) id ivar; +@end + +@implementation TestB +- (id)ivar { + __attribute__((__blocks__(byref))) id value = ((void*)0); + void (^b)() = ^{ value = _ivar; }; + b(); + return value; +} +- (void)setIvar:(id)newValue { + void (^b)() = ^{ [_ivar release]; _ivar = [newValue retain]; }; + b(); +} +@end |