// C++ IA64 / g++ v3 demangler -*- C++ -*-
-// Copyright (C) 2003 Free Software Foundation, Inc.
+// Copyright (C) 2003, 2004 Free Software Foundation, Inc.
// Written by Carlo Wood <carlo@alinoe.com>
//
// This file is part of the GNU ISO C++ Library. This library is free
#include <vector>
#include <string>
+#include <ext/new_allocator.h>
#ifndef _GLIBCXX_DEMANGLER_DEBUG
#define _GLIBCXX_DEMANGLER_CWDEBUG 0
{
namespace demangler
{
-
enum substitution_nt
{
type,
pointer_to_member = 'M'
};
- template<typename Allocator>
+ template<typename Tp, typename Allocator = __gnu_cxx::new_allocator<Tp> >
class qualifier;
- template<typename Allocator>
+ template<typename Tp, typename Allocator = __gnu_cxx::new_allocator<Tp> >
class qualifier_list;
- template<typename Allocator>
+ template<typename Tp, typename Allocator = __gnu_cxx::new_allocator<Tp> >
class session;
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
class qualifier
{
typedef typename Allocator::template rebind<char>::other
#endif
};
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
class qualifier_list
{
typedef typename Allocator::template rebind<char>::other
private:
mutable bool M_printing_suppressed;
- typedef qualifier<Allocator> qual;
+ typedef qualifier<Tp, Allocator> qual;
typedef typename Allocator::template rebind<qual>::other qual_Allocator;
typedef std::vector<qual, qual_Allocator> qual_vector;
qual_vector M_qualifier_starts;
- session<Allocator>& M_demangler;
+ session<Tp, Allocator>& M_demangler;
void decode_KVrA(string_type& prefix, string_type& postfix, int cvq,
typename qual_vector::
const_reverse_iterator const& iter_array) const;
public:
- qualifier_list(session<Allocator>& demangler_obj)
+ qualifier_list(session<Tp, Allocator>& demangler_obj)
: M_printing_suppressed(false), M_demangler(demangler_obj)
{ }
int start_pos,
int inside_substitution)
{ M_qualifier_starts.
- push_back(qualifier<Allocator>(start_pos,
+ push_back(qualifier<Tp, Allocator>(start_pos,
simple_qualifier, inside_substitution)); }
void
int count,
int inside_substitution)
{ M_qualifier_starts.
- push_back(qualifier<Allocator>(start_pos,
+ push_back(qualifier<Tp, Allocator>(start_pos,
cv_qualifier, &M_demangler.M_str[start_pos],
count, inside_substitution)); }
string_type optional_type,
int inside_substitution)
{ M_qualifier_starts.
- push_back(qualifier<Allocator>(start_pos,
+ push_back(qualifier<Tp, Allocator>(start_pos,
param_qualifier, optional_type, inside_substitution)); }
void
{ return false; }
};
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
class session
{
- friend class qualifier_list<Allocator>;
+ public:
+ friend class qualifier_list<Tp, Allocator>;
typedef typename Allocator::template rebind<char>::other
char_Allocator;
typedef std::basic_string<char, std::char_traits<char>, char_Allocator>
bool
decode_type(string_type& output,
- qualifier_list<Allocator>* qualifiers = NULL)
+ qualifier_list<Tp, Allocator>* qualifiers = NULL)
{
string_type postfix;
bool res = decode_type_with_postfix(output, postfix, qualifiers);
int number_of_prefixes);
bool decode_type_with_postfix(string_type& prefix,
- string_type& postfix, qualifier_list<Allocator>* qualifiers = NULL);
+ string_type& postfix, qualifier_list<Tp, Allocator>* qualifiers = NULL);
bool decode_bare_function_type(string_type& output);
bool decode_builtin_type(string_type& output);
bool decode_call_offset(string_type& output);
bool decode_operator_name(string_type& output);
bool decode_source_name(string_type& output);
bool decode_substitution(string_type& output,
- qualifier_list<Allocator>* qualifiers = NULL);
+ qualifier_list<Tp, Allocator>* qualifiers = NULL);
bool decode_template_args(string_type& output);
bool decode_template_param(string_type& output,
- qualifier_list<Allocator>* qualifiers = NULL);
+ qualifier_list<Tp, Allocator>* qualifiers = NULL);
bool decode_unqualified_name(string_type& output);
bool decode_unscoped_name(string_type& output);
bool decode_non_negative_decimal_integer(string_type& output);
bool decode_real(string_type& output, size_t size_of_real);
};
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
#if !_GLIBCXX_DEMANGLER_CWDEBUG
inline
#endif
void
- session<Allocator>::add_substitution(int start_pos,
+ session<Tp, Allocator>::add_substitution(int start_pos,
substitution_nt sub_type,
int number_of_prefixes = 0)
{
// ::= 1|2|3|4|5|6|7|8|9 [<digit>+]
// <digit> ::= 0|1|2|3|4|5|6|7|8|9
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::
+ session<Tp, Allocator>::
decode_non_negative_decimal_integer(string_type& output)
{
char c = current();
// <number> ::= [n] <non-negative decimal integer>
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_number(string_type& output)
+ session<Tp, Allocator>::decode_number(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_number");
if (current() != 'n')
};
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_builtin_type(string_type& output)
+ session<Tp, Allocator>::decode_builtin_type(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_builtin_type");
char const* bt;
// <class-enum-type> ::= <name>
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_class_enum_type(string_type& output)
+ session<Tp, Allocator>::decode_class_enum_type(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_class_enum_type");
string_type nested_name_qualifiers;
// 0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
// [<seq-id>] # Base 36 number
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_substitution(string_type& output,
- qualifier_list<Allocator>* qualifiers)
+ session<Tp, Allocator>::decode_substitution(string_type& output,
+ qualifier_list<Tp, Allocator>* qualifiers)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_substitution");
unsigned int value = 0;
// <template-param> ::= T_ # first template parameter
// ::= T <parameter-2 non-negative number> _
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_template_param(string_type& output,
- qualifier_list<Allocator>* qualifiers)
+ session<Tp, Allocator>::decode_template_param(string_type& output,
+ qualifier_list<Tp, Allocator>* qualifiers)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_template_parameter");
if (current() != 'T')
_GLIBCXX_DEMANGLER_RETURN;
}
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_real(string_type& output, size_t size_of_real)
+ session<Tp, Allocator>::decode_real(string_type& output, size_t size_of_real)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_real");
_GLIBCXX_DEMANGLER_RETURN;
}
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_literal(string_type& output)
+ session<Tp, Allocator>::decode_literal(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_literal");
eat_current(); // Eat the 'L'.
{ "ix", "operator[]", unary }
};
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_operator_name(string_type& output)
+ session<Tp, Allocator>::decode_operator_name(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_operator_name");
// ::= L <type> <value float> E # floating literal
// ::= L <mangled-name> E # external name
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_expression(string_type& output)
+ session<Tp, Allocator>::decode_expression(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_expression");
if (current() == 'T')
// ::= L <type> <value float> E # floating literal
// ::= L <mangled-name> E # external name
// ::= X <expression> E # expression
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_template_args(string_type& output)
+ session<Tp, Allocator>::decode_template_args(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_template_args");
if (eat_current() != 'I')
// our <bare-function-type> slightly different from the one in
// the C++-ABI description.
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_bare_function_type(string_type& output)
+ session<Tp, Allocator>::decode_bare_function_type(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_bare_function_type");
if (M_saw_destructor)
// number of A's in the series.
// In the function below, iter_array points to the first (right most)
// A in the series, if any.
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
void
- qualifier_list<Allocator>::decode_KVrA(
+ qualifier_list<Tp, Allocator>::decode_KVrA(
string_type& prefix, string_type& postfix, int cvq,
typename qual_vector::const_reverse_iterator const& iter_array) const
{
_GLIBCXX_DEMANGLER_RETURN3;
}
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
void
- qualifier_list<Allocator>::decode_qualifiers(
+ qualifier_list<Tp, Allocator>::decode_qualifiers(
string_type& prefix,
string_type& postfix,
bool member_function_pointer_qualifiers = false) const
}
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_type_with_postfix(
+ session<Tp, Allocator>::decode_type_with_postfix(
string_type& prefix, string_type& postfix,
- qualifier_list<Allocator>* qualifiers)
+ qualifier_list<Tp, Allocator>* qualifiers)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING2("decode_type");
++M_inside_type;
++count;
c = next();
}
- qualifier_list<Allocator> class_type_qualifiers(*this);
+ qualifier_list<Tp, Allocator> class_type_qualifiers(*this);
if (count)
class_type_qualifiers.
add_qualifier_start(cv_qualifier, Q2_start_pos,
// ::= <template-param>
// ::= <substitution>
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_nested_name(string_type& output,
+ session<Tp, Allocator>::decode_nested_name(string_type& output,
string_type& qualifiers)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_nested_name");
// := Z <function encoding> E s [<discriminator>]
// <discriminator> := _ <non-negative number>
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_local_name(string_type& output)
+ session<Tp, Allocator>::decode_local_name(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_local_name");
if (current() != 'Z' || M_pos >= M_maxpos)
// <source-name> ::= <positive length number> <identifier>
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_source_name(string_type& output)
+ session<Tp, Allocator>::decode_source_name(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_source_name");
int length = current() - '0';
// ::= <ctor-dtor-name> # Starts with 'C' or 'D'.
// ::= <source-name> # Starts with a digit.
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_unqualified_name(string_type& output)
+ session<Tp, Allocator>::decode_unqualified_name(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_unqualified_name");
if (M_inside_template_args)
// <unqualified-name> # Starts not with an 'S'
// St <unqualified-name> # ::std::
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_unscoped_name(string_type& output)
+ session<Tp, Allocator>::decode_unscoped_name(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_unscoped_name");
if (current() == 'S')
//
// <unscoped-template-name> ::= <unscoped-name>
// ::= <substitution>
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_name(string_type& output,
+ session<Tp, Allocator>::decode_name(string_type& output,
string_type& nested_name_qualifiers)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_name");
//
// <v-offset> ::= <offset number> _ <virtual offset number>
// virtual base override, with vcall offset
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_call_offset(string_type&
+ session<Tp, Allocator>::decode_call_offset(string_type&
#if _GLIBCXX_DEMANGLER_CWDEBUG
output
#endif
// second call-offset is result
// adjustment
//
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
bool
- session<Allocator>::decode_special_name(string_type& output)
+ session<Tp, Allocator>::decode_special_name(string_type& output)
{
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_special_name");
if (current() == 'G')
// character.
// <data name> # Idem.
// <special-name> # Starts with 'T' or 'G'.
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
int
- session<Allocator>::decode_encoding(string_type& output,
+ session<Tp, Allocator>::decode_encoding(string_type& output,
char const* in, int len, implementation_details const& id)
{
#if _GLIBCXX_DEMANGLER_CWDEBUG
#endif
if (len <= 0)
return INT_MIN;
- session<Allocator> demangler_session(in, len, id);
+ session<Tp, Allocator> demangler_session(in, len, id);
string_type nested_name_qualifiers;
int saved_pos;
demangler_session.store(saved_pos);
} // namespace demangler
// Public interface
- template<typename Allocator>
+ template<typename Tp, typename Allocator>
struct demangle
{
typedef typename Allocator::template rebind<char>::other char_Allocator;
//
// Demangle `input' which should be a mangled function name as for
// instance returned by nm(1).
- template<typename Allocator>
- typename demangle<Allocator>::string_type
- demangle<Allocator>::symbol(char const* input,
+ template<typename Tp, typename Allocator>
+ typename demangle<Tp, Allocator>::string_type
+ demangle<Tp, Allocator>::symbol(char const* input,
demangler::implementation_details const& id)
{
// <mangled-name> ::= _Z <encoding>
// <mangled-name> ::= _GLOBAL_ _<type>_ <disambiguation part>
// <type> can be I or D (GNU extension)
- typedef demangler::session<Allocator> demangler_type;
+ typedef demangler::session<Tp, Allocator> demangler_type;
string_type result;
bool failure = (input[0] != '_');
// demangle::type()
// Demangle `input' which must be a zero terminated mangled type
// name as for instance returned by std::type_info::name().
- template<typename Allocator>
- typename demangle<Allocator>::string_type
- demangle<Allocator>::type(char const* input,
+ template<typename Tp, typename Allocator>
+ typename demangle<Tp, Allocator>::string_type
+ demangle<Tp, Allocator>::type(char const* input,
demangler::implementation_details const& id)
{
std::basic_string<char, std::char_traits<char>, Allocator> result;
result = "(null)";
else
{
- demangler::session<Allocator> demangler_session(input, INT_MAX, id);
+ demangler::session<Tp, Allocator> demangler_session(input, INT_MAX, id);
if (!demangler_session.decode_type(result)
|| demangler_session.remaining_input_characters())
{
}
return result;
}
-
} // namespace __gnu_cxx
#endif // __DEMANGLE_H
-# Makefile.in generated by automake 1.7.9 from Makefile.am.
+# Makefile.in generated by automake 1.7.8 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
-ATOMICITY_INC_SRCDIR = @ATOMICITY_INC_SRCDIR@
+ATOMICITY_SRCDIR = @ATOMICITY_SRCDIR@
+ATOMIC_WORD_SRCDIR = @ATOMIC_WORD_SRCDIR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
exception new typeinfo cxxabi.h exception_defines.h
+c_sources = \
+ cp-demangle.c
+
+
sources = \
del_op.cc \
del_opnt.cc \
vterminate.cc
-libsupc___la_SOURCES = $(sources)
-libsupc__convenience_la_SOURCES = $(sources)
+libsupc___la_SOURCES = $(sources) $(c_sources)
+libsupc__convenience_la_SOURCES = $(sources) $(c_sources)
glibcxxinstalldir = $(gxx_include_dir)
glibcxxinstall_HEADERS = $(headers)
"gxx_include_dir=$(gxx_include_dir)"
+# Use special rules for pulling things out of libiberty. These
+# objects should be compiled with the "C" compiler, not the C++
+# compiler, and also should not use the C++ includes.
+C_INCLUDES = -I.. -I$(toplevel_srcdir)/libiberty -I$(toplevel_srcdir)/include
+C_COMPILE = \
+ $(CC) $(DEFS) $(C_INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+
+
+# LTCOMPILE is copied from LTCXXCOMPILE below.
+LTCOMPILE = $(LIBTOOL) --tag CC --tag disable-shared --mode=compile $(CC) \
+ $(DEFS) $(C_INCLUDES) $(LIBSUPCXX_PICFLAGS) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+
+
# libstdc++ libtool notes
# 1) Need to explicitly set LTCXXCOMPILE so that AM_CXXFLAGS is
eh_terminate.lo eh_throw.lo eh_type.lo eh_unex_handler.lo \
guard.lo new_handler.lo new_op.lo new_opnt.lo new_opv.lo \
new_opvnt.lo pure.lo tinfo.lo tinfo2.lo vec.lo vterminate.lo
-am_libsupc___la_OBJECTS = $(am__objects_1)
+am__objects_2 = cp-demangle.lo
+am_libsupc___la_OBJECTS = $(am__objects_1) $(am__objects_2)
libsupc___la_OBJECTS = $(am_libsupc___la_OBJECTS)
libsupc__convenience_la_LDFLAGS =
libsupc__convenience_la_LIBADD =
-am_libsupc__convenience_la_OBJECTS = $(am__objects_1)
+am_libsupc__convenience_la_OBJECTS = $(am__objects_1) $(am__objects_2)
libsupc__convenience_la_OBJECTS = $(am_libsupc__convenience_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp =
am__depfiles_maybe =
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
all: all-am
.SUFFIXES:
-.SUFFIXES: .cc .lo .o .obj
+.SUFFIXES: .c .cc .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/fragment.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign libsupc++/Makefile
distclean-compile:
-rm -f *.tab.c
+.c.o:
+ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+ $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+
+.c.lo:
+ $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
+
.cc.o:
$(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
uninstall-info-am uninstall-toolexeclibLTLIBRARIES
+cp-demangle.c:
+ rm -f $@
+ $(LN_S) $(toplevel_srcdir)/libiberty/cp-demangle.c $@
+cp-demangle.lo: cp-demangle.c
+ $(LTCOMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
+cp-demangle.o: cp-demangle.c
+ $(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
+
# We have to have rules modified from the default to counteract SUN make
# prepending each of $(glibcxxinstall_HEADERS) with VPATH below.
install-glibcxxinstallHEADERS: $(glibcxxinstall_HEADERS)
+++ /dev/null
-// C++ IA64 / g++ v3 demangler -*- C++ -*-
-
-// Copyright (C) 2003, 2004 Free Software Foundation, Inc.
-// Written by Carlo Wood <carlo@alinoe.com>
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-#include <bits/demangle.h>
-#include <cxxabi.h>
-
-// __cxa_demangle
-//
-// Demangle a C++ symbol or type name.
-//
-// `mangled-name' is a pointer to a null-terminated array of characters.
-// It may be either an external name, i.e. with a "_Z" prefix, or an
-// internal NTBS mangling, e.g. of a type for type_info.
-//
-// `buf' may be null. If it is non-null, then n must also be non-null,
-// and buf is a pointer to an array, of at least *n characters, that
-// was allocated using malloc.
-//
-// `status' points to an int that is used as an error indicator. It is
-// permitted to be null, in which case the user just doesn't get any
-// detailed error information.
-//
-// Returns: a pointer to a null-terminated array of characters, the
-// demangled name. Or NULL in case of failure.
-//
-// If there is an error in demangling, the return value is a null pointer.
-// The user can examine *status to find out what kind of error occurred.
-// Meaning of error indications:
-//
-// * 0: success
-// * -1: memory allocation failure
-// * -2: invalid mangled name
-// * -3: invalid arguments (e.g. buf nonnull and n null)
-//
-
-namespace __cxxabiv1
-{
- namespace
- {
- char* const error = 0;
-
- enum status_codes
- {
- success = 0,
- memory_allocation_failure = -1,
- invalid_mangled_name = -2,
- invalid_argument = -3
- };
-
- inline char*
- failure(status_codes error_code, int* status)
- {
- if (status)
- *status = error_code;
- return error;
- }
-
- char*
- finish(char const* demangled_name, size_t demangled_name_size,
- char* buf, size_t* n, int* status)
- {
- if (!buf || *n < demangled_name_size + 1)
- {
- if (n)
- *n = demangled_name_size + 1;
- buf = (char*)realloc(buf, demangled_name_size + 1);
- if (!buf)
- return failure(memory_allocation_failure, status);
- }
- if (status)
- *status = success;
- std::strncpy(buf, demangled_name, demangled_name_size);
- buf[demangled_name_size] = 0;
- return buf;
- }
- } // namespace
-
- char*
- __cxa_demangle(char const* mangled_name, char* buf, std::size_t* n,
- int* status)
- {
- try {
- using namespace __gnu_cxx;
- typedef demangler::session<std::allocator<char> > session_type;
-
- if (!mangled_name || (buf && !n))
- return failure(invalid_argument, status);
-
- std::string result;
- if (mangled_name[0] == '_')
- {
- // External name?
- if (mangled_name[1] == 'Z')
- {
- // C++ name?
- int cnt = session_type::
- decode_encoding(result, mangled_name + 2, INT_MAX);
- if (cnt < 0 || mangled_name[cnt + 2] != 0)
- return failure(invalid_mangled_name, status);
- return finish(result.data(), result.size(), buf, n, status);
- }
- else if (mangled_name[1] == 'G')
- {
- // Possible _GLOBAL__ extension?
- if (!std::strncmp(mangled_name, "_GLOBAL__", 9)
- && (mangled_name[9] == 'D' || mangled_name[9] == 'I')
- && mangled_name[10] == '_')
- {
- if (mangled_name[9] == 'D')
- result.assign("global destructors keyed to ", 28);
- else
- result.assign("global constructors keyed to ", 29);
- // Output the disambiguation part as-is.
- result += mangled_name + 11;
- return finish(result.data(), result.size(), buf, n, status);
- }
- }
- }
-
- // Ambiguities are possible between extern "C" object names and
- // internal built-in type names, e.g. "i" may be either an object
- // named "i" or the built-in "int" type. Such ambiguities should
- // be resolved to user names over built-in names. Builtin types
- // are any single lower case character. Any other single
- // character is not a mangled type so we can treat those the same
- // here.
- if (mangled_name[1] == 0)
- return finish(mangled_name, 1, buf, n, status);
-
- // Not a built-in type or external name, try to demangle input as
- // NTBS mangled type name.
- session_type demangler_session(mangled_name, INT_MAX);
- if (!demangler_session.decode_type(result)
- || demangler_session.remaining_input_characters())
- {
- // Failure to demangle, assume extern "C" name.
- result = mangled_name;
- }
- return finish(result.data(), result.size(), buf, n, status);
- } catch (std::bad_alloc&) {
- return failure(memory_allocation_failure, status);
- }
- }
-} // namespace __cxxabiv1
-
-// Explicit instantiations.
-namespace __gnu_cxx
-{
- template class demangler::qualifier_list<std::allocator<char> >;
- template class demangler::session<std::allocator<char> >;
-} // namespace __gnu_cxx
-
-namespace std
-{
- template
- void vector<int>::_M_insert_aux(vector<int>::iterator, const int&);
-
- typedef __gnu_cxx::demangler::substitution_st value_type1;
- template
- void vector<value_type1>::_M_insert_aux(vector<value_type1>::iterator,
- const value_type1&);
-
- typedef __gnu_cxx::demangler::qualifier<std::allocator<char> > value_type2;
- template
- void vector<value_type2>::_M_insert_aux(vector<value_type2>::iterator,
- const value_type2&);
-}
-