[cfe-dev] Get "real" type name.
Layus via cfe-dev
cfe-dev at lists.llvm.org
Tue Jan 26 12:57:48 PST 2016
Thanks Yaron and Stephan,
Using QualType::dump(), I found
Decl.getType()->getAs<TemplateSpecializationType>()->getArg(0).getAsType().getAsString()
!
I had to go back in the code as my former specDecl had already lost the
real type information.
QualType::dump() is a killer feature !
Guillaume.
On 25/01/16 19:55, Yaron Keren via cfe-dev wrote:
> Useful trick to see how such things are done is to debug into the
> QualType::dump() method.
>
>
> 2016-01-25 18:48 GMT+02:00 Stephan Bergmann via cfe-dev
> <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>>:
>
> On 01/25/2016 05:15 PM, Guillaume Maudoux (Layus) via cfe-dev wrote:
>
> I am currently fighting with clang libs to get the "real" type
> name of a
> template parameter.
> My current code obtains the "resolved" name of the type.
>
> For example, with a `typedef int myInt;`,
> templateArgs[0].getAsType().getAsString() returns "int"
> instead of "myInt".
>
> const TemplateArgumentList& templateArgs =
> specDecl->getTemplateArgs();
>
> assert(templateArgs.size() == 1);
> assert(templateArgs[0].getKind() == TemplateArgument::Type);
> return
> templateArgs[0].getAsType().getAsString(context->getPrintingPolicy());
>
> Is there some way to extract the type string used in the
> source code,
> not the type infered by clang ?
>
>
> Asked something similar two years ago,
> <http://lists.llvm.org/pipermail/cfe-dev/2014-February/035161.html> "SubstTemplateTypeParmType
> and non-canonical replacement type." But never found an answer.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160126/a0a2fab0/attachment.html>
More information about the cfe-dev
mailing list