<div dir="ltr">Thanks, this is very helpful.<br><p class=""><span class="">clang-query>match recordDecl(hasDescendant(fieldDecl(hasType(anyOf(builtinType(), pointerType()))))<br><br>will find a class with pointer or builtin types. I'm not sure how to record this to make use of it later. </span></p><p class="">I want to find any constructor (ignoring implicit ones for now) which triggered this first match but left one of its builtin or pointer fields uninitialised. I can't yet see how to iterate over fields as the information I care about is which ones are not initialised and they'll be missing from whatever constructor expression I'm matching.</p><p class="">I can live with false positives in the constructor body for now.</p><p class="">regards,</p><p class="">Jon</p><p class=""><span class=""><br></span></p><p class=""><span class=""><br></span></p><p class=""><span class=""><br></span></p></div><div class="gmail_extra"><br><div class="gmail_quote">On 2 February 2015 at 19:25, Richard <span dir="ltr"><<a href="mailto:legalize@xmission.com" target="_blank">legalize@xmission.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
In article <<a href="mailto:CAAbBDD_qERV4xufHtjBjgQT9m-1AsxretLTS_ABvQGGkeAOX%2BA@mail.gmail.com">CAAbBDD_qERV4xufHtjBjgQT9m-1AsxretLTS_ABvQGGkeAOX+A@mail.gmail.com</a>>,<br>
<span class="">    Jonathan Coe <<a href="mailto:jbcoe@me.com">jbcoe@me.com</a>> writes:<br>
<br>
> I'm looking to make use of a clang-tidy check that would find (and<br>
> optionally value-initialise) primitive class members (pointers, int,<br>
> doubles etc).<br>
><br>
> class C<br>
> {<br>
>   int x_;<br>
> public:<br>
>   C() {} // no x_()<br>
> };<br>
><br>
> Is this:<br>
><br>
> 1) Already possible? (I can't find it)<br>
<br>
</span>I believe so.<br>
<span class=""><br>
> 2) Already work in progress? (I'd like to participate)<br>
<br>
</span>I am interested in clang-tidy checkers/fixers that identify the same<br>
issues as cppcheck and this is something that they identify currently.<br>
You can use cppcheck as a reference checking mechanism.<br>
<br>
> 3) Possible at all?<br>
<br>
Yes.<br>
<span class=""><br>
> 3. Is motivated by my very weak understanding of the matchers, I'm not sure<br>
> if I can match things that are missing if the missing things depend on the<br>
> node I'm looking at. It would be nice to match the compiler generated<br>
> constructor too (and generate one) if that would fail to initialise<br>
> primitives as required.<br>
<br>
</span>I would play with clang-query and experiment with the matchers that<br>
you need to identify:<br>
<br>
- a class with POD members<br>
- a constructor for a class containing POD members<br>
<br>
Maybe you just match all class declarations and all constructors and<br>
you walk through the other information in code in order to identify<br>
"class with POD members".<br>
<br>
Your check can maintain state, so you can note that you don't have to<br>
do everything with your matcher.  You can record that you saw a class<br>
with POD members and that a c'tor was declared but not defined so<br>
that when you see the definition after the declaration you know this<br>
is a definition you should drill into more carefully.<br>
<br>
Remember that POD members can also be initialized by assignment in the<br>
c'tor, so you'll want to have that to avoid false positives.<br>
<br>
Start with the simplest case that you can identify accurately and<br>
correct.  A tool that works correctly for a subset of cases is still<br>
useful.  You can incrementally enhance the check over time to extend<br>
it to more elaborate cases.<br>
<br>
Work out of trunk.  A bunch of changes have been made to clang-tidy in<br>
trunk compared to 3.5.<br>
<br>
The best thing is probably to post questions to the list as you<br>
encounter them.<br>
<span class="HOEnZb"><font color="#888888">--<br>
"The Direct3D Graphics Pipeline" free book <<a href="http://tinyurl.com/d3d-pipeline" target="_blank">http://tinyurl.com/d3d-pipeline</a>><br>
     The Computer Graphics Museum <<a href="http://ComputerGraphicsMuseum.org" target="_blank">http://ComputerGraphicsMuseum.org</a>><br>
         The Terminals Wiki <<a href="http://terminals.classiccmp.org" target="_blank">http://terminals.classiccmp.org</a>><br>
  Legalize Adulthood! (my blog) <<a href="http://LegalizeAdulthood.wordpress.com" target="_blank">http://LegalizeAdulthood.wordpress.com</a>><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</font></span></blockquote></div><br></div>