Extend IdenticalExprChecker to find more potential problems

Daniel Marjamäki Daniel.Marjamaki at evidente.se
Mon Feb 10 23:56:22 PST 2014


Hello!

Thank you Daniel for extending the IdenticalExprChecker. Imho these checks are very useful.

About such code:

if (foo()) {
        doSomething();
} else if (bar()) {
        /* no action needed */
} else {
        /* FIXME: Implement this. */
}

You could warn here. However there will some noise.

In my opinion it is not very rare to have identical blocks of code in if and else blocks by intention. My feeling is that for instance MISRA enforce some identical blocks because there must always be an empty else if the "else" logic should be to do nothing.

Here is one real code example where there are identical blocks by intention. The TODO means that the code could be enhanced but it's fine for now.
https://github.com/danmar/cppcheck/blob/6bfd4af5/lib/checkunusedvar.cpp#L528

I have not tried your patch yet though. I have access to some misra compatible code I could test it on.

Best regards,
Daniel Marjamäki

..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile:                 +46 (0)709 12 42 62
E-mail:                 Daniel.Marjamaki<mailto:Daniel.Marjamaki at evidente.se>@evidente.se<mailto:Daniel.Marjamaki at evidente.se>

www.evidente.se
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140211/a87ad012/attachment.html>


More information about the cfe-commits mailing list