The llvm-cxxfilt tool has a --types
flag that can be used to demangle a type (e.g. llvm-cxxfilt --types i
-> int
).
This would also be extremely useful for libcxxrt (which embeds the elftoolchain demangler) since __cxa_demangle
needs to be able to demangle types.
Updating the demangler inside libcxxrt broke type demangling and currently requires local patches (https://github.com/libcxxrt/libcxxrt/commit/7b2335c14f93cdf18815a393e2c80e8dbb9149f3)
Would it be possible to add a variant of __cxa_demangle_gnu3(const char *org)
that takes an additional boolean/flag argument to allow demangling types rather than just function names?
Thanks for filing the ticket - I will be keeping this in mind.
The demangler code needs a relook for sure. I'm investigating whether we could derive the core of the demangler directly from the formal grammar for mangled names (available at https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling).