[cfe-dev] How to get typedef name?

Miklos Vajna via cfe-dev cfe-dev at lists.llvm.org
Sun Nov 3 12:53:39 PST 2019


Hi Kenth,

On Thu, Oct 31, 2019 at 03:41:22PM +0000, Kenth Eriksson via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> How can I get the underlying typedef name for the parameters of
> a FunctionDecl?  
> 
> The following gives the resolved typedef name, but I want the typedef
> name. 
> 
> func->parameters()[i]->getType().getAsString();

Care to share a short, self-contained example?

I just tried this on a function that takes an std::string (which is
typically a typedef) and I got std::string by default.

If you want to get the "desugared" type, then you would need to dyn_cast
to clang::TypedefType, then desugar().getAsString().

Regards,

Miklos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191103/d358727f/attachment.sig>


More information about the cfe-dev mailing list