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.
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 // Detect that ivar is in use, if used in category in the same file as the
50 //===----------------------------------------------------------------------===//
51 @protocol Protocol6260004
55 @interface RDar6260004 {
60 @implementation RDar6260004 @end
61 @implementation RDar6260004 (Protocol6260004)
67 //===----------------------------------------------------------------------===//
68 // ivars referenced by lexically nested functions should not be flagged as
70 //===----------------------------------------------------------------------===//
71 @interface RDar7254495 {
77 @implementation RDar7254495
78 int radar_7254495(RDar7254495 *a) {
83 //===----------------------------------------------------------------------===//
84 // Consult attribute((unused)) to silence warnings about unused instance
86 //===----------------------------------------------------------------------===//
87 @interface RDar7353683 {
89 id x __attribute__((unused));
93 @implementation RDar7353683
96 //===----------------------------------------------------------------------===//
97 // Unused bitfield ivars trigger cause weird diagnostic:
98 // "Instance variable '' in class..."
99 //===----------------------------------------------------------------------===//
100 @interface RDar8481311 {
102 unsigned bitfield:1; // expected-warning {{Instance variable 'bitfield' in class 'RDar8481311' is never used}}
106 @implementation RDar8481311
110 @interface Radar11059352_1 {
112 NSString *_pathString;
114 @property (readonly, strong) NSString *pathString;
117 @interface Radar11059352 {
119 Radar11059352_1 *_workspacePath;
123 @implementation Radar11059352
125 - (void)useWorkspace {
126 NSString *workspacePathString = _workspacePath.pathString;