<div dir="ltr">Thank you both for your input. <div><br></div><div>I think I will dig into it over the weekend. Hopefully I can make a little headway with it :)</div><div><br></div><div>Best regards,</div><div>Mads Ravn</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 9, 2017 at 6:02 PM Samuel Benzaquen <<a href="mailto:sbenza@google.com">sbenza@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg">On Mon, Dec 26, 2016 at 3:45 PM, Mads Ravn <span dir="ltr" class="gmail_msg"><<a href="mailto:madsravn@gmail.com" class="gmail_msg" target="_blank">madsravn@gmail.com</a>></span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Hi,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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)" class="gmail_msg">TODO:</span><span style="line-height:1.5;color:rgb(192,192,192)" class="gmail_msg"> </span><span style="line-height:1.5;color:rgb(0,128,0)" class="gmail_msg">Here</span><span style="line-height:1.5;color:rgb(192,192,192)" class="gmail_msg"> </span><span style="line-height:1.5;color:rgb(0,128,0)" class="gmail_msg">is</span><span style="line-height:1.5;color:rgb(192,192,192)" class="gmail_msg"> </span><span style="line-height:1.5;color:rgb(0,128,0)" class="gmail_msg">the</span><span style="line-height:1.5;color:rgb(192,192,192)" class="gmail_msg"> </span><span style="line-height:1.5;color:rgb(0,128,0)" class="gmail_msg">list</span><span style="line-height:1.5;color:rgb(192,192,192)" class="gmail_msg"> </span><span style="line-height:1.5;color:rgb(0,128,0)" class="gmail_msg">of</span><span style="line-height:1.5;color:rgb(192,192,192)" class="gmail_msg"> </span><span style="line-height:1.5;color:rgb(0,128,0)" class="gmail_msg">the</span><span style="line-height:1.5;color:rgb(192,192,192)" class="gmail_msg"> </span><span style="line-height:1.5;color:rgb(0,128,0)" class="gmail_msg">missing</span><span style="line-height:1.5;color:rgb(192,192,192)" class="gmail_msg"> </span><span style="line-height:1.5;color:rgb(0,128,0)" class="gmail_msg">matchers,</span><span style="line-height:1.5;color:rgb(192,192,192)" class="gmail_msg"> </span><span style="line-height:1.5;color:rgb(0,128,0)" class="gmail_msg">grouped</span><span style="line-height:1.5;color:rgb(192,192,192)" class="gmail_msg"> </span><span style="line-height:1.5;color:rgb(0,128,0)" class="gmail_msg">by</span><span style="line-height:1.5;color:rgb(192,192,192)" class="gmail_msg"> </span><span style="line-height:1.5;color:rgb(0,128,0)" class="gmail_msg">reason." - </span><span style="line-height:1.5" class="gmail_msg">here 'equals' is listed under 'Other'.</span></div><div class="gmail_msg"><span style="line-height:1.5" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="line-height:1.5" class="gmail_msg">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 class="gmail_msg"><br class="gmail_msg"></div></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">I put it in the list.</div><div class="gmail_msg">It requires more work than seemed appropriate at the time.</div><div class="gmail_msg">The function is a template, which we don't support yet in the dynamic matcher layer.</div><div class="gmail_msg">Also, it supports types that are not supported in the parser, like floats.<br class="gmail_msg"></div></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg"> </div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><span style="line-height:1.5" class="gmail_msg"> 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 class="gmail_msg"><span style="line-height:1.5" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="line-height:1.5" class="gmail_msg">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 class="gmail_msg"><br class="gmail_msg"></div></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">I think the "easiest" way is to make a custom dynamic matcher.</div><div class="gmail_msg">But we tried very hard not to make these.</div><div class="gmail_msg">Instead, we made the original matchers compatible to make sure we are running the same code in both.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">There are a couple ways to make this work:</div><div class="gmail_msg"> 1) Remove the template on equals() and list all the overloads we want manually.</div><div class="gmail_msg"> 2) Make equals a functor, add a type list of "accepted types" and add a special marshaller for that pattern.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">(2) is a lot of work, but would be a generic solution.</div><div class="gmail_msg">This is how polymorphic matchers work.</div><div class="gmail_msg">However, I think for this case (1) is best. I don't know if we would reuse the generality of (2).</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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 class="gmail_msg"><br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><span style="line-height:1.5" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="line-height:1.5" class="gmail_msg">Best regards,</span></div><div class="gmail_msg"><span style="line-height:1.5" class="gmail_msg">Mads Ravn</span></div></div>
</blockquote></div><br class="gmail_msg"></div></div>
</blockquote></div>