[cfe-commits] Removing redundant default cases
David Blaikie
dblaikie at gmail.com
Fri Sep 23 21:33:50 PDT 2011
Hi Ted,
I tried -Wunreachable-code earlier today (Chandler had suggested it as a way
to find/remove the dead code after llvm_unreachables I'd migrated yesterday)
& it produced some very... interesting output. It did find the dead code
after llvm_unreachable but it also found some other very strange cases. I
was wondering what was up with that. Good to know it's WIP - any tips on the
state of that? anywhere I'd be able to lend a hand?
It wouldn't catch all the same cases ("case N: default: stuff" for example)
but this solution isn't great either, it'll catch a variety of arcane cases
that won't have trivial fixes. Chandler had mentioned the idea of this
warning (well, something like it) yesterday but after I threw this together
we were talking about it more & realized it'd be pretty tricky to get right
with a nice multiline fixit that is very reliable (I get the impression
that's what he's really interested in - really low (0?) false positive rate
& accurate fixits - which would be awesome, but require a rather different
fix)
Just figured I'd throw it out there for any thoughts, but mostly looking to
CR the mechanical change, make sure my understanding of the coding
convention was correct before I checked it in.
Have a good weekend,
- David
On Fri, Sep 23, 2011 at 9:17 PM, Ted Kremenek <kremenek at apple.com> wrote:
> There is a WIP warning, -Wunreachable-code, that actually does a
> reachability analysis on the CFG. It's not completely ready for prime time,
> but it is getting there. Does it catch all of these cases? If so, I'm not
> certain if we need a separate warning, although this one looks fairly cheap.
>
> On Sep 23, 2011, at 7:20 PM, David Blaikie wrote:
>
> > I hacked up a cheap version of a warning for defaults in switches that
> already cover all cases in an enum (the warning is in excess_default.diff -
> given some discussion with Chandler on IRC I don't think we consider this to
> be sufficiently high quality to be checked in, but I wouldn't mind some
> other opinions/thoughts (the issue was that it might need to use the CFG to
> ensure that it's not reachable via loops nested in the switch or gotos,
> fallthroughs etc)) and I found/fixed the following cases
> (excess_default_fixes.diff)
> >
> <excess_default.diff><excess_default_fixes.diff>_______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110923/44a14374/attachment.html>
More information about the cfe-commits
mailing list