[LLVMbugs] [Bug 18137] New: -Wunused-property-ivar false positive with non-trivial setter override

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Dec 4 12:14:50 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=18137

            Bug ID: 18137
           Summary: -Wunused-property-ivar false positive with non-trivial
                    setter override
           Product: new-bugs
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: sean at rogue-research.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11666
  --> http://llvm.org/bugs/attachment.cgi?id=11666&action=edit
repro case

With today's svn trunk, i.e.:

$ clang --version
clang version 3.5 (196392)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

I get a false positive from -Wunused-property-ivar with this code:

------------------
#import <Foundation/Foundation.h>

@interface Foo : NSObject
@property (readwrite, copy, nonatomic) NSArray* array;
@end

@implementation Foo

@synthesize array = _array;
- (void)setArray:(NSArray*)inArray
{
    NSMutableArray* lameCopy = [NSMutableArray array];
#if 1
    for (id obj in inArray)
    {
        [lameCopy addObject:obj];
    }
#endif

    _array = lameCopy;
}

@end

int main (void)
{
    return 0;
}
------------------

clang -fsyntax-only -Wunused-property-ivar ~/Desktop/test.m

/Users/sean/Desktop/test.m:10:1: warning: ivar '_array' which backs the
property is not referenced in this property's accessor [-Wunused-property-ivar]
- (void)setArray:(NSArray*)inArray
^
/Users/sean/Desktop/test.m:4:49: note: property declared here
@property (readwrite, copy, nonatomic) NSArray* array;


If I toggle the "#if 1" to "#if 0" the warning goes away, oddly.  I see many
similar false positives in my actual codebase.

This warning seems to have been added in r193439 for <rdar://14989999> by
fjahanian.

If this exists in 3.4, please fix it there before 3.4 release.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131204/21f8831a/attachment.html>


More information about the llvm-bugs mailing list