<div dir="ltr"><div dir="ltr">On Fri, 26 Jun 2020 at 11:30, Robert Ankeney <<a href="mailto:rrankene@gmail.com">rrankene@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks Richard! This works great! One more question - assuming I have a templated class CClass, how would I match tVal for:<div>void myFunc(CClass<T>* tVal) ?<br></div></div></blockquote><div><br></div><div>It depends exactly what you're looking for. If you don't care what CClass is, and want to match any pointer to X<..., T, ...>, then something like:</div><div><br></div><div>varDecl(hasType(pointerType(pointee(templateSpecializationType(hasAnyTemplateArgument(refersToType(templateTypeParmType())))))))<br></div><div><br></div><div>might be what you're looking for. If you want to match a T *anywhere* in the variable's type, then maybe something like:</div><div><br></div><div>m varDecl(hasType(qualType(hasDescendant(qualType(templateTypeParmType())))))<br></div><div><br></div><div>is what you want. <a href="https://godbolt.org/z/QhGN5d">https://godbolt.org/z/QhGN5d</a></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>Oh, and thanks also for the godbolt link. I didn't realize you could do match testing there!</div><div><br></div><div>Robert</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 24, 2020 at 10:38 AM Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>The declarations of tVal and tParam can be matched by</div><div> varDecl(hasType(templateTypeParmType()))</div><div>The use of tVal can be matched by</div><div> declRefExpr(hasDeclaration(varDecl(hasType(templateTypeParmType()))))</div><div><br></div><div><a href="https://godbolt.org/z/B3SuC3" target="_blank">https://godbolt.org/z/B3SuC3</a><br><div><br></div><div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 23 Jun 2020 at 15:47, Robert Ankeney via cfe-users <<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I'm looking for a matcher for variables whose type is a template parameter. For example:<div><br></div><div>template<typename T></div><div>T tVal; // Match tVal</div><div>int func(T tParam); // Match tParam</div><div>int i = func(tVal); // Match tVal</div><div><br></div><div>Our coding standards require the variable to have a 't' at the start of the variable name.</div><div>Looking at the matcher reference, I didn't see anything obvious. Can anyone point me the right direction?</div><div><br></div><div>Many thanks,</div><div>Robert</div><div><br></div></div>
_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div></div>