<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Manuel,<div><br></div><div>I completely missed those predicates - thank you!</div><div><br></div><div>How do I get the full name of an instantiated template recordDecl?</div><div><br></div><div>As in:</div><div>template <class T> class X;</div><div>class A;</div><div><br></div><div>X<A> xa;</div><div><br></div><div>If a varDecl(…) matches on xa - how do I get the "X<A>” name?</div><div><br></div><div>Best,</div><div><br></div><div>.Chris.<br><div apple-content-edited="true">
Christian Schafmeister<br><a href="mailto:chris.schaf@verizon.net">chris.schaf@verizon.net</a><br><br>
</div>
<br><div><div>On Feb 20, 2014, at 12:53 AM, Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>hasAncestor(decl(anyOf(recordDecl(</div><div> isTemplateInstantiation()),</div><div> functionDecl(isTemplateInstantiation()))</div><div><br></div><div>should do what you want.</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Feb 19, 2014 at 11:01 PM, Christian Schafmeister <span dir="ltr"><<a href="mailto:chris.schaf@verizon.net" target="_blank">chris.schaf@verizon.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><br></div><div>If I match a varDecl() that is in a method of a template class I get a match for the template and instantiated templates </div><div>- is there a way to tell the difference by matching some difference in the ancestors of the varDecl node?</div>
<div><br></div><div>I get a match for the translate::from_object<T> a0(*args); varDecl in the method activate (see below) that has this type:</div><div>from_object<type-parameter-0-0, struct std::__1::integral_constant<_Bool, true> ></div>
<div><br></div><div>I also get a match that I think is from the instantiation TestFunctoid<int> j(“test”) in tinyFunc - it has this type: "struct translate::from_object<int, std::true_type>"</div><div>
<br></div><div>There is a clear difference in the name - but I was looking for something that didn’t feel like a hack.</div><div><br></div><div>Are there differences in the AST class node for TestFunctoid when it is a template class vs when it is an instantiated template class?</div>
<div><br></div><div><br></div><div><font face="Courier"><br></font></div><div><div><font face="Courier">#include <stdio.h></font></div><div><font face="Courier">#include <core/foundation.h></font></div><div><font face="Courier">#include <core/object.h></font></div>
<div><font face="Courier">#include <core/holder.h></font></div><div><font face="Courier"><br></font></div><div><font face="Courier">namespace asttooling {</font></div><div><font face="Courier"><br></font></div><div>
<font face="Courier"><br></font></div><div><font face="Courier"> template<typename T></font></div><div><font face="Courier"> class TestFunctoid : public core::Functoid {</font></div><div><font face="Courier"> public:</font></div>
<div><font face="Courier"><br></font></div><div><font face="Courier"> TestFunctoid(const string& name) : core::Functoid(name) {};</font></div><div><font face="Courier"> core::T_mv activate( core::const_ActivationFrame_spREF closedOverFrame, int numArgs, ArgArray args )</font></div>
<div><font face="Courier"> {</font></div><div><font face="Courier"> translate::from_object<T> a0(*args);</font></div><div><font face="Courier"> printf( "Address of a0= %p\n", &a0);</font></div>
<div><font face="Courier"> return Values0<core::T_O>();</font></div><div><font face="Courier"> }</font></div><div><font face="Courier"> };</font></div><div><font face="Courier"><br></font></div>
<div><font face="Courier"><br></font></div><div><font face="Courier"><br></font></div><div><font face="Courier"> void tinyFunc()</font></div><div><font face="Courier"> {</font></div><div><font face="Courier"> TestFunctoid<int> j("test");</font></div>
<div><font face="Courier"> TinyStruct x(10);</font></div><div><font face="Courier"> tinyFunc(x);</font></div><div><font face="Courier"> printf("Hi there, this is tinyFunc\n");</font></div><div>
<font face="Courier"> }</font></div><div><font face="Courier"><br></font></div><div><font face="Courier">};</font></div></div><div><br></div><div>
<div><div>Christian Schafmeister</div><div>Associate Professor</div><div>Chemistry Department</div><div>Temple University</div></div>
</div>
<br></div></blockquote></div><br></div>
</blockquote></div><br></div></body></html>