[cfe-dev] [clang-tidy] Check for paranoic code (pointer checking)

Breno Guimarães via cfe-dev cfe-dev at lists.llvm.org
Fri Mar 17 10:55:25 PDT 2017


Hi guys,

Thanks for all the suggestions! I'm starting to run my check in our code
base (around 2M C++ lines) and the ratio of good findings and noise.

But as many of you said, there are already several well agreed guidelines
that can be checked, and I will start picking some of them and produce the
checks. Hopefully I can contribute very soon (I can only play with this at
nights and weekends, but still...).

I also liked the idea of adding configurations and tweaks to existing
checks. That's a good way to see how the APIs are used and what's available.

I appreciate the responses!

Best regards,
Breno G.



On Thu, Mar 16, 2017 at 6:51 PM, Richard via cfe-dev <cfe-dev at lists.llvm.org
> wrote:

>
> [Please reply *only* to the list and do not include my email directly
> in the To: or Cc: of your reply; otherwise I will not see your reply.
> Thanks.]
>
> In article <CAAt6xTtzDzbTmKwi_RjTuJt70mZ7RHL1GbR_
> 2Bi5EUJTMSFBiA at mail.gmail.com>,
>     Aaron Ballman via cfe-dev <cfe-dev at lists.llvm.org> writes:
>
> > On Thu, Mar 16, 2017 at 12:54 AM, Breno Guimarães via cfe-dev
> > <cfe-dev at lists.llvm.org> wrote:
> >
> > > 2 - Any feedback on this specific check?
> >
> > Adding some intelligence to the check so that it suggests removing the
> > validity check, or suggests replacing the pointer with a reference,
> > when sensible to do so would make this a much better check IMO.
>
> One very common case from programmers with a C background is to check
> the result of new against NULL/nullptr/0.  Other static analyzers like
> cppcheck have such a check already.  If clang/clang-tidy doesn't
> already warn on code like this, that would be a good addition.
>
> Another check in the same spirit is where code checks for non-nullptr
> at some point and then checks against nullptr again.  This usually
> happens in large functions where the earlier check against nullptr is
> "out of sight, out of mind" when someone is adding the second check
> against nullptr.
>
> Again, this would be a welcome addition to clang/clang-tidy if we
> don't already have something like that.
> --
> "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-
> pipeline>
>             The Terminals Wiki <http://terminals-wiki.org>
>      The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
>   Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>


-- 
Breno Rodrigues Guimarães
Universidade Federal de Minas Gerais - UFMG, Brasil
(Federal University of Minas Gerais, Brazil)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170317/a928ff60/attachment.html>


More information about the cfe-dev mailing list