<div dir="ltr">UPDATE: I still haven't figured out the issue with the getCanonicalTemplateSpecializationType() API, but I have found another API which does the job just fine. What I do is the following:<div><br></div><div>void *InsertPos;</div><div>ClassTemplateSpecializationDecl *TD = MyClassTemplateDecl->findSpecialization(Args, InsertPos);</div><div>if (!TD) {</div><div>  TD = ClassTemplateSpecializationDecl::Create(...);</div><div>  MyClassTemplateDecl->AddSpecialization(TD, InsertPos);</div><div>}</div><div><br></div><div>QualType FullyQualTemplateType(TD->getTypeForDecl());</div><div><br></div><div>Indeed, the FullyQualTemplateType includes the namespace(s) in which MyClassTemplateDecl was declared. So in the example above, it is the type "foo::bar<int>".</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 2, 2016 at 5:18 PM, scott constable <span dir="ltr"><<a href="mailto:sdconsta@syr.edu" target="_blank">sdconsta@syr.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi All,<br><br>I'm trying to use the getCanonicalTemplateSpecializationType() function from the ASTContext API to generate a TemplateSpecializationType. The API works just fine, except in the case where the Template class is qualified, e.g. with a namespace. For example, if I process the following code:<br><br>namespace foo {<br>template<typename T>bar {};<br>}<br><br>and generate a template specialization with an "int" argument, the result is "bar<int>" whereas it should be "foo::bar<int>". The reason, it seems, is an oddity in getCanonicalTemplateSpecializationType()'s implementation:<br><br>ASTContext.cpp:<br>3529  // Look through qualified template names.<br>3530  if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())<br>3531  Template = TemplateName(QTN->getTemplateDecl());<br><div><br></div><div>So essentially the ASTContext is just throwing away the namespace qualifier (I'm giving it a QualifiedTemplateName as an argument). Is this a bug? Am I using the wrong api?</div><div><br></div><div>Thanks in advance,</div><div><br></div><div>Scott Constable</div></div>
</blockquote></div><br></div>