[cfe-dev] Using clang-tool to Exact type names in template specification arguments

Oliver Zhang via cfe-dev cfe-dev at lists.llvm.org
Wed Aug 12 20:13:58 PDT 2020


I'm using clang-tool to extract type names in template arguments. For

typedef unsigned int vectors32_t[32];
> template <typename T>
> func(T *const vec) {
>     ...
> }
> int main() {
>     ...
>     func<vector32_t>(...);
>     ...
> }

I'd like to get the type name "vector32_t" from func's template argument.
So I use clang::FunctionDecl::getTemplateSpecializationArgs() to get func's
template argument list, extract the argument from the list, and then try to
get the type name for the argument by using
clang::TemplateArgument::getAsType().getAsString(). However, "unsigned int
[32]" is returned rather than "vector32_t".

Any thoughts on how I can extract the type alias name "vector32_t" in my
above example?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200813/729894e3/attachment.html>

More information about the cfe-dev mailing list