[cxx-abi-dev] __cxa_demangle of type manglings
Dennis Handly
dhandly at cup.hp.com
Tue Jan 11 01:20:38 UTC 2005
>From: Jason Merrill <jason at redhat.com>
>The ABI specification says that the argument to __cxa_demangle can be
>'either an external name, i.e. with a "_Z" prefix, or an internal NTBS
>mangling, e.g. of a type for type_info', and later that
We had a customer that insisted that __cxa_demangle work for type_info
so their code would be portable.
>Such ambiguities should be resolved to user names over built-in names.'
Darn, I can't read. :-(
I didn't implement this. Probably this would have made the customer unhappy.
Unfortunately making it a type caused a bunch of other components (debugger
and compiler error messages) to change their code but we had them all change.
>It seems to me that the specified behavior makes __cxa_demangle useless for
>type manglings, since most of them are also valid C++ identifiers, and
>therefore could be an extern "C" object name.
Whether it is extern C or not, object names aren't mangled. extern "C"
is only important for functions.
>I think that the ambiguity should be resolved the other way by default,
Yes. The ABI was broken. There never should have been any ambiguity.
I don't think the cost of 2 bytes per string was worth it.
>and that we should add another way to specify that the argument is an
>external name, probably via another entry point.
Jason
There is no need to have another entry. If it doesn't start with "_Z"
it is a type or a non-mangled object or function name.
That was our solution to the debugger. (They don't care about type_infos.)
If it doesn't start with "_Z", then don't call __cxa_demangle.
One other special thing I did for c++filt, where I added advanced AI
technology, if you have a file, it only demangles tokens if it starts with
"_Z". If you provide the string on the command line, it assumes you want
to demangle a type_info.
(This seems to be what gnu c++filt (3.2) does.)
More information about the cxx-abi-dev
mailing list