<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 26, 2016 at 3:45 PM, Mads Ravn <span dir="ltr"><<a href="mailto:madsravn@gmail.com" target="_blank">madsravn@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I have been wondering how to implement 'equals' for integer literals in clang-query. It doesn't seem to be working for string literals either. In Registry.cpp it says: "<span style="line-height:1.5;color:rgb(0,128,0)">TODO:</span><span style="line-height:1.5;color:rgb(192,192,192)"> </span><span style="line-height:1.5;color:rgb(0,128,0)">Here</span><span style="line-height:1.5;color:rgb(192,192,192)"> </span><span style="line-height:1.5;color:rgb(0,128,0)">is</span><span style="line-height:1.5;color:rgb(192,192,192)"> </span><span style="line-height:1.5;color:rgb(0,128,0)">the</span><span style="line-height:1.5;color:rgb(192,192,192)"> </span><span style="line-height:1.5;color:rgb(0,128,0)">list</span><span style="line-height:1.5;color:rgb(192,192,192)"> </span><span style="line-height:1.5;color:rgb(0,128,0)">of</span><span style="line-height:1.5;color:rgb(192,192,192)"> </span><span style="line-height:1.5;color:rgb(0,128,0)">the</span><span style="line-height:1.5;color:rgb(192,192,192)"> </span><span style="line-height:1.5;color:rgb(0,128,0)">missing</span><span style="line-height:1.5;color:rgb(192,192,192)"> </span><span style="line-height:1.5;color:rgb(0,128,0)">matchers,</span><span style="line-height:1.5;color:rgb(192,192,192)"> </span><span style="line-height:1.5;color:rgb(0,128,0)">grouped</span><span style="line-height:1.5;color:rgb(192,192,192)"> </span><span style="line-height:1.5;color:rgb(0,128,0)">by</span><span style="line-height:1.5;color:rgb(192,192,192)"> </span><span style="line-height:1.5;color:rgb(0,128,0)">reason." - </span><span style="line-height:1.5">here 'equals' is listed under 'Other'.</span></div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">So I guess there is a reason why it is not working for clang-query. Does anyone know what this reason is?</span></div></div></blockquote><div><br></div><div>I put it in the list.</div><div>It requires more work than seemed appropriate at the time.</div><div>The function is a template, which we don't support yet in the dynamic matcher layer.</div><div>Also, it supports types that are not supported in the parser, like floats.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="line-height:1.5"> I wouldn't mind fixing it, but the few things I have tried have all resulted in failures. I am not sure why it works in clang-tidy, but not in clang-query. Aren't they using the same code-base for matchers? I can see equals implemented in ASTMatchers.h, but why can't clang-query use that?</span></div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">Can anyone point me in the right direction as how to implement this in clang-query? I imagine there is some blocking issue since it is not implemented already.</span></div></div></blockquote><div><br></div><div>I think the "easiest" way is to make a custom dynamic matcher.</div><div>But we tried very hard not to make these.</div><div>Instead, we made the original matchers compatible to make sure we are running the same code in both.</div><div><br></div><div>There are a couple ways to make this work:</div><div> 1) Remove the template on equals() and list all the overloads we want manually.</div><div> 2) Make equals a functor, add a type list of "accepted types" and add a special marshaller for that pattern.</div><div><br></div><div>(2) is a lot of work, but would be a generic solution.</div><div>This is how polymorphic matchers work.</div><div>However, I think for this case (1) is best. I don't know if we would reuse the generality of (2).</div><div><br></div><div>Another option similar to (1) is to add the specific overloads we want in clang-query and leave the template to handle everything else.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">Best regards,</span></div><div><span style="line-height:1.5">Mads Ravn</span></div></div>
</blockquote></div><br></div></div>