[cfe-commits] [scan-build][PATCH 1/1] Unreachable code checker : false positive in switch statements ?

Ted Kremenek kremenek at apple.com
Tue Feb 28 23:11:46 PST 2012


On Feb 28, 2012, at 10:29 PM, David Blaikie <dblaikie at gmail.com> wrote:

> Should we just change the way the CFG is built to include edges for
> default labels on covered switches all the time? That would fix the
> same bug (I'm on the fence about whether it is a bug, myself) in
> Clang's -Wunreachable-code.

Hi David,

Besides the technical solution I proposed in my other email, I thought I'd add one more thing.

>From a design perspective, I don't believe what you propose would even be the right balance.  All the other analyses in clang, the dataflow based warnings, the static analyzer, etc., are fine with the current CFG with respect to how 'default' labels are handled.  Should we really weaken the CFG, thus degrading the precision of all of these analyses, just to make this one warning easier to implement?

Even if I didn't have an idea for a potentially general solution to allow the CFG to better service everyone (and I'm not saying it is perfect; we'd have to evaluate it if we are interested), this seems like the wrong tradeoff to me.  If this was a pervasive problem for clients of the CFG, then I think it would be worth considering, but that's why I proposed the "ghost edges" idea as a possible way to satisfy multiple clients, including -Wunreachable-code.

Ted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120228/4d395fd9/attachment.html>


More information about the cfe-commits mailing list