Typedef type as template argument

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() 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.)