1 // RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=osx.cocoa.UnusedIvars -verify -Wno-objc-root-class %s
3 //===--- BEGIN: Delta-debugging reduced headers. --------------------------===//
7 - (oneway void)release;
9 @interface NSObject <NSObject> {}
14 //===--- END: Delta-debugging reduced headers. ----------------------------===//
16 // This test case tests the basic functionality of the unused ivar test.
19 int x; // expected-warning {{Instance variable 'x' in class 'TestA' is never used}}
22 @implementation TestA @end
24 // This test case tests whether the unused ivar check handles blocks that
25 // reference an instance variable. (<rdar://problem/7075531>)
26 @interface TestB : NSObject {
28 id _ivar; // no-warning
30 @property (readwrite,retain) id ivar;
35 __attribute__((__blocks__(byref))) id value = ((void*)0);
36 void (^b)(void) = ^{ value = _ivar; };
41 - (void)setIvar:(id)newValue {
42 void (^b)(void) = ^{ [_ivar release]; _ivar = [newValue retain]; };
47 //===----------------------------------------------------------------------===//
48 // <rdar://problem/6260004> Detect that ivar is in use, if used in category
49 // in the same file as the implementation
50 //===----------------------------------------------------------------------===//
52 @protocol Protocol6260004
56 @interface RDar6260004 {
61 @implementation RDar6260004 @end
62 @implementation RDar6260004 (Protocol6260004)
68 //===----------------------------------------------------------------------===//
69 // <rdar://problem/7254495> - ivars referenced by lexically nested functions
70 // should not be flagged as unused
71 //===----------------------------------------------------------------------===//
73 @interface RDar7254495 {
79 @implementation RDar7254495
80 int radar_7254495(RDar7254495 *a) {
85 //===----------------------------------------------------------------------===//
86 // <rdar://problem/7353683> - consult attribute((unused)) to silence warnings
87 // about unused instance variables
88 //===----------------------------------------------------------------------===//
90 @interface RDar7353683 {
92 id x __attribute__((unused));
96 @implementation RDar7353683
98 //===----------------------------------------------------------------------===//
99 // <rdar://problem/8481311> Unused bitfield ivars trigger cause weird
100 // diagnostic: "Instance variable '' in class..."
101 //===----------------------------------------------------------------------===//
103 @interface RDar8481311 {
105 unsigned bitfield:1; // expected-warning {{Instance variable 'bitfield' in class 'RDar8481311' is never used}}
109 @implementation RDar8481311
113 @interface Radar11059352_1 {
115 NSString *_pathString;
117 @property (readonly, strong) NSString *pathString;
120 @interface Radar11059352 {
122 Radar11059352_1 *_workspacePath;
126 @implementation Radar11059352
128 - (void)useWorkspace {
129 NSString *workspacePathString = _workspacePath.pathString;