Interpreting C++ Demangled Names |
Some
SAS/C components, such as the COOL pre-linker and the SAS/C Debugger, need
to refer to overloadable names in their messages and reports, as in COOL diagnostic
messages or debugger prompts to select one of several overloaded functions.
In these contexts, a routine called the demangler is called
to generate a demangled name, which is an approximation to the
original C++ declaration of the name. For instance, the demangled form of reciprocal_ _Fd
is reciprocal(double)
. The demangled
name may fail to match the actual declaration
of an object for any of several reasons:
-
The mangled name may not contain enough information
to completely reproduce the original form. For instance, if a type is defined
using a typedef, the typedef name is not present in the mangled name. For
example:
typedef container box;
bool open(box *);
The demangled form of this open
function will be open(container *)
.
-
In some cases, a demangled name may not even be
valid C++. This can happen when valid C++ code requires the use of a
typedef
. For example:
typedef void (*functionp)(int);
class example {
operator functionp(); /* convert example to functionp */
}
The demangled name for example::operator functionp
above will be
example::operator
void(*)(int)()
, which is not an acceptable syntax for a conversion
operator.
-
In many contexts where mangled names are used,
a limited amount of space is available to display the name. Not only are
many C++ names long in their original form, but the expansion of typedefs
can result in very long names for functions whose declarations are quite short.
For instance, the complete demangled name of an extraction operator in the
standard template library is as follows:
std::basic_ostream<char,std::char_traits<char> >::operator <<
(std::basic_ostream<char,std::char_traits<char> >&(*)
(std::basic_ostream<char,std::char_traits<char> >&))
Names such as that above generally must be compressed
in some fashion in order to fit in a fixed-size field. Such compression loses
information, and also produces a name that is not valid for C++. For example,
the name above, in a COOL cross-reference, will possibly be compacted to the
following:
std::basic_stream<char,std::char_traits<char> >::operator <<(...1)
Of course, this is not a valid C++ operator specification,
and all information about the type of the argument has been lost. The combination
of these factors can make demangled names quite difficult to interpret.
Note:
See the information the information on the endisplaylimit
COOL
option in
SAS/C Compiler and Library User's Guide for information about
generating non-compacted names.
The remainder of this section describes the special
conventions used in demangled names as an aid to figuring out the specific
identifier a demangled name refers to.
Copyright © 2001
by SAS Institute Inc., Cary, NC, USA. All rights reserved.