[LLVMbugs] [Bug 16958] New: -Wshadow-ivar fires at point of use

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 21 12:27:40 PDT 2013


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

            Bug ID: 16958
           Summary: -Wshadow-ivar fires at point of use
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: gwynne at darkrainfall.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The warning controlled by -Wshadow-ivar (declaration shadows instance variable)
for Objective-C is issued at every instance where such the shadowing variable
is used, rather than at the point of the shadowing declaration. For example:

@interface A : NSObject
@end

@implementation A
{
    NSString * __weak _str;
}

- (void)doSomethingHere
{
   _Pragma("clang diagnostic push");
   _Pragma("clang diagnostic ignored \"-Wshadow\"");
   _Pragma("clang diagnostic ignored \"-Wshadow-ivar\"");
   NSString * __strong _str = _str; // -Wshadow-ivar does not fire here
   _Pragma("clang diagnostic pop");

   NSLog(@"%@", _str); // -Wshadow-ivar DOES fire here
   [self doSomethingElseWith:_str]; // -Wshadow-ivar fires again here
}

@end

This makes it impractical to deliberately shadow instance variables. A common
use case is temporarily taking a strong reference to a weak ivar, as in the
example given.

-- 
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/20130821/064398c1/attachment.html>


More information about the llvm-bugs mailing list