<div dir="ltr">On Thu, Mar 21, 2013 at 12:27 PM, Abir Basak <span dir="ltr"><<a href="mailto:abirbasak@gmail.com" target="_blank">abirbasak@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br clear="all"><div><div style="font-size:13px;font-family:arial,sans-serif">
I am new to clang AST. I am trying to write a program which rewrites all locations in a TU where template alias are used.</div>
<div style="font-size:13px;font-family:arial,sans-serif"><br></div><div style="font-size:13px;font-family:arial,sans-serif">say, given</div><div style="font-size:13px;font-family:arial,sans-serif">
<br></div><div style="font-size:13px;font-family:arial,sans-serif">1. template<class T,class U = T></div><div style="font-size:13px;font-family:arial,sans-serif">2. class class_1{};</div>
<div style="font-size:13px;font-family:arial,sans-serif">3. template<class U></div><div style="font-size:13px;font-family:arial,sans-serif">4. using alias1 = class_1<U>; </div>
<div style="font-size:13px;font-family:arial,sans-serif"><div>5. template<class T,class U></div><div>6. using alias2 = class_1<T,U>; </div><div>7.</div><div>8. template<class X,class Y = alias1<X> ></div>

<div>9. void foo(...)</div><div>10. {</div><div>11.   alias2<int,X> x = ...; <br>12. }</div><div><br></div><div>I am interested to transform all references to template alias to something like typename alias1<X>::type, typename alias2<int,X>::type x = ... etc, and may be optionally remove the 'typename' part if the resulting type is not dependent.</div>

<div>I am using C++ API with RAV, and presently can get all template alias decl using </div>Visit/Traverse TypeAliasTemplateDecl, but has no idea how to get all references to them, such as at line 8 & 11 , irrespective to their name.</div>
</div></div></blockquote><div><br></div><div style>I have not dealt with template aliases yet, but I'd expect it pretty much to work like for any other type declaration:</div><div style>In line (8) you have a TemplateTypeParmDecl whose getDefaultArgument will yield a type (not sure which one exactly, I expect something like TemplateSpecializationType), whose declaration will be the TypeAliasDecl.</div>
<div style>In line (11) you have a declaration with the given type.</div><div style><br></div><div style>With RAV, you'll want to visit TypeLoc's and check that those type locs refer to your template alias decl.</div>
<div style><br></div><div style>Cheers,</div><div style>/Manuel</div><div style><br></div><div style> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div>
<div style="font-size:13px;font-family:arial,sans-serif"><br></div><div style="font-size:13px;font-family:arial,sans-serif">Any help will be appreciated. </div><div style="font-size:13px;font-family:arial,sans-serif">
Thank you.</div></div>
</div>
<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>
<br></blockquote></div><br></div></div>