<div dir="ltr">Hi,<div><br></div><div>I'm trying to translate Template arguments (as part of a source to source translation tool). Therefore I need only to consider explicit arguments (as written in the source)</div><div>
<br></div><div>However the TemplateArgument I receive always have random kind numbers (when static casting to int and print them) therefore I never get the kind of the argument and can't translate the arguments.</div>
<div><br></div><div>My code looks as follows</div><div><br></div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(255,255,85)">if</span><span style="color:rgb(170,170,170)">(</span>declRefExpr<span style="color:rgb(170,170,170)">-></span>hasExplicitTemplateArgs<span style="color:rgb(170,170,170)">())</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(170,170,170)">{</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(255,255,85)"> unsigned</span><span style="color:rgb(192,192,192)"> </span>templateArgs<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(170,170,170)">=</span><span style="color:rgb(192,192,192)"> </span>declRefExpr<span style="color:rgb(170,170,170)">-></span>getNumTemplateArgs<span style="color:rgb(170,170,170)">();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font color="#c0c0c0"> </font><span style="color:rgb(255,255,85)">auto</span><span style="color:rgb(192,192,192)"> </span>astTemplateArgsList<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(170,170,170)">=</span><span style="color:rgb(192,192,192)"> </span>declRefExpr<span style="color:rgb(170,170,170)">-></span>getExplicitTemplateArgs<span style="color:rgb(170,170,170)">();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font color="#c0c0c0"> </font><span style="color:rgb(255,255,85)">for</span><span style="color:rgb(170,170,170)">(</span><span style="color:rgb(255,255,85)">unsigned</span><span style="color:rgb(192,192,192)"> </span>i<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(170,170,170)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(255,85,255)">0</span><span style="color:rgb(170,170,170)">;</span><span style="color:rgb(192,192,192)"> </span>i<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(170,170,170)"><</span><span style="color:rgb(192,192,192)"> </span>templateArgs<span style="color:rgb(170,170,170)">;</span><span style="color:rgb(192,192,192)"> </span>i<span style="color:rgb(170,170,170)">++)</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>astTemplateArgsList<span style="color:rgb(170,170,170)">[</span>i<span style="color:rgb(170,170,170)">].</span>getArgument<span style="color:rgb(170,170,170)">()</span></pre>
<div><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(170,170,170)">}</span> </div><div><br></div><div>Does anyone see what is wrong with this code or where could be the error?</div><div><br></div><div>
Furthermore I looked into the implementation of getTemplateArgs() (which is called by the [] operator) <a href="http://clang.llvm.org/doxygen/TemplateBase_8h_source.html#l00561">http://clang.llvm.org/doxygen/TemplateBase_8h_source.html#l00561</a> there it is just return "this+1" with a cast which is quite un-intuitive but I guess it is correct?</div>
<div><br></div><div>Thanks for any help.</div><div><br></div><div>Lukas</div></div>