<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div style="-webkit-text-size-adjust: auto;">On Feb 17, 2014, at 12:43 AM, David Come <<a href="mailto:davidbrcz@gmail.com">davidbrcz@gmail.com</a>> wrote:</div><div style="-webkit-text-size-adjust: auto;"><br></div><blockquote type="cite" style="-webkit-text-size-adjust: auto;"><div><div dir="ltr"><p>Hello !<br></p><p>I'm writing a small software to translate header into C++ files.
It works fine for non-template class but I'm having n issue with
template class, especially with template class's constructor or
destructor.</p>
<p>I'm using <code>CXXMethodDecl::getNameAsString</code> to get the name of the function.
For a non template class like <br></p><pre style="" class=""><code><span class=""> </span><span class="">struct</span><span class=""> C
</span><span class="">{</span><span class="">
C</span><span class="">();</span><span class="">
</span><span class="">~</span><span class="">C</span><span class="">();</span><span class="">
</span><span class="">//other stuff</span><span class="">
</span><span class="">}</span></code></pre>
<p>The previous function gives me (as I expect) <code>C</code> and <code>~C</code>.</p>
<p>But if the class is template like the following:</p>
<pre style="" class=""><code><span class=""> </span><span class="">template</span><span class=""> </span><span class=""><</span><span class="">class</span><span class=""> TT</span><span class="">,</span><span class="">int</span><span class=""> N</span><span class="">></span><span class="">
</span><span class="">struct</span><span class=""> C
</span><span class="">{</span><span class="">
C</span><span class="">();</span><span class="">
</span><span class="">~</span><span class="">C</span><span class="">();</span><span class="">
</span><span class="">}</span></code></pre>
<p>I get as result : <code>C<TT, N></code> and <code>~C<TT, N></code>,
which is not what I was expecting. <br></p><p>For me, the name of a function should not be independent of the class
being template. Classic functions behave the way I expect (same name in
both cases).</p><p><br></p>
<p>Am I missing something ? Is this the normal behavior or a bug ?</p></div></div></blockquote><div style="-webkit-text-size-adjust: auto;">I'm new to this myself, but:</div><div style="-webkit-text-size-adjust: auto;"><br></div><div style="-webkit-text-size-adjust: auto;">1. This sounds like a question better-suited for cfe-dev, not llvmdev.</div><div style="-webkit-text-size-adjust: auto;"><br></div><div style="-webkit-text-size-adjust: auto;">2. NamedDecl::getNameAsString() is deprecated; use getName() instead.</div><div style="-webkit-text-size-adjust: auto;"><br></div><div><span style="-webkit-text-size-adjust: auto;">3. NamedDecl also as getDeclName(), which is documented to return “</span><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0);">the actual, stored name of the declaration, which may be a special name.”</span></div><div><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0);">--Kyle Sluder</span></div></body></html>