[cfe-dev] [libClang] Get name of method parameter or variable type
Jacob Carlborg via cfe-dev
cfe-dev at lists.llvm.org
Mon Jun 12 12:40:43 PDT 2017
On 2017-06-11 22:13, Sam Vanheer via cfe-dev wrote:
> I'm trying to get the name of method parameter and variable types, but
> the name returned by clang_getTypeSpelling contains part of the type as
> used, like "const", "&", etc.
>
> Is there any way to use libClang's API to get just the name of the type,
> without any of these additions? I'm currently removing these from the
> name manually, but it seems superfluous when Clang already has it.
To get the name of a parameter you want to use clang_getCursorSpelling.
To get the name of the type for the tool [1] that I've built I'm using
clang_getCursorType and then a big switch [2] on the type kind, similar
to what Jonathan Müller suggested.
[1] https://github.com/jacob-carlborg/dstep
[2]
https://github.com/jacob-carlborg/dstep/blob/master/dstep/translator/Type.d#L27
--
/Jacob Carlborg
More information about the cfe-dev
mailing list