[cfe-dev] Typedef type as template argument

Richard Smith richard at metafoo.co.uk
Tue Nov 4 20:15:00 PST 2014

On Tue, Nov 4, 2014 at 5:44 AM, Gabor Kozar <kozargabor at gmail.com> wrote:

>  I have a FunctionDecl that is an instantiated FunctionTemplateDecl. I
> want to figure out if the template argument is a typedef type -
> unfortunately, the TemplateArgument only contains the desugared type. This
> makes sense, given the way templates work, but it's inconvenient.
> Is there any way for me to get the actual type that the user instantiated
> the template with? I tried getTemplateSpecializationArgsAsWritten
> <http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html#a8a5ee203ad0c4a166d12656b2a7cccbb>()
> but it seems to always return NULL.

Each user of the FunctionDecl might have different template arguments
(using different ways of writing the same type, for instance), so this
information isn't on the FunctionDecl. Look at the DeclRefExpr in the user
of the function; it will have the template arguments written in the call.
(FunctionDecl's getTemplateSpecializationArgsAsWritten is for explicit
specializations and the like, where the function template specialization is
explicitly written somewhere.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141104/f60bde77/attachment.html>

More information about the cfe-dev mailing list