[LLVMbugs] [Bug 9189] New: Spurious results in self = [self -init] test

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 10 02:15:25 PST 2011


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

           Summary: Spurious results in self = [self -init] test
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: csdavec at swan.ac.uk
                CC: llvmbugs at cs.uiuc.edu


The missing "self = [(super or self) init...]" test in the static analyser
looks like a nice idea, but I've run it on our codebase, seen over a thousand
reports, and so far every single one of them that I've checked has been a false
positive, which makes the test a bit less useful.

One common case is in -initWithCoder:.  Classes implementing this method should
only call [super initWithCoder:] if the superclass implements the NSCoding
protocol.  

I'm not sure what the best way of solving this is.  Ideally, we want two extra
annotations:

1) Specifying a designated initialiser for a class, so that all subclasses are
required to call that initialiser

2) Specify that an initialiser is expected to only call itself in the
superclass (annotation on the method declaration in the protocol).  This is
true for -initWithCoder: and a few other things.  This could actually be a more
general annotation, saying that a subclass implementation of any method is
expected to call the superclass version if it exists, but with a special case
for init*: methods, where it overrides the need to call [{self,super} init].

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list