Get "real" type name.


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);

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, <> "SubstTemplateTypeParmType and non-canonical replacement type." But never found an answer.

Useful trick to see how such things are done is to debug into the QualType::dump() method.

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 !