[multiple changes]

2004-02-26  Ian Lance Taylor  <ian@wasabisystems.com>

	* testsuite/demangle/abi_examples/01.cc: Expect error -2.
	* testsuite/demangle/abi_examples/02.cc: Likewise.
	* testsuite/demangle/regression/cw-11.cc: Likewise.
	* testsuite/demangle/regression/cw-16.cc: Change two expected
	results to match libiberty demangler output.

2004-02-26  Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/10246
        * libsupc++/Makefile.am: Use libiberty demangler.
        (c_sources): Add cp-demangle.c.
        * libsupc++/Makefile.in: Regenerate.
        * src/Makefile.am (sources): Remove demangle.cc.
        * src/Makefile.in: Regenerate.
        * include/Makefile.am (bits_headers): Move demangle.h.
	(ext_headers): ...here.
        * include/Makefile.in: Regenerate.
        * include/bits/demangle.h: Move...
	* include/ext/demangle.h: ...here.
        * src/demangle.cc: Remove.

2004-02-26  Benjamin Kosnik  <bkoz@redhat.com>

        * include/bits/demangle.h: Add type template parameter to all
        templates with just an Allocator template parameter.

From-SVN: r78553
This commit is contained in:
Benjamin Kosnik 2004-02-27 03:21:16 +00:00
parent d095928f0f
commit 40fcf31b2f
13 changed files with 206 additions and 305 deletions

View File

@ -1,3 +1,31 @@
2004-02-26 Ian Lance Taylor <ian@wasabisystems.com>
* testsuite/demangle/abi_examples/01.cc: Expect error -2.
* testsuite/demangle/abi_examples/02.cc: Likewise.
* testsuite/demangle/regression/cw-11.cc: Likewise.
* testsuite/demangle/regression/cw-16.cc: Change two expected
results to match libiberty demangler output.
2004-02-26 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/10246
* libsupc++/Makefile.am: Use libiberty demangler.
(c_sources): Add cp-demangle.c.
* libsupc++/Makefile.in: Regenerate.
* src/Makefile.am (sources): Remove demangle.cc.
* src/Makefile.in: Regenerate.
* include/Makefile.am (bits_headers): Move demangle.h.
(ext_headers): ...here.
* include/Makefile.in: Regenerate.
* include/bits/demangle.h: Move...
* include/ext/demangle.h: ...here.
* src/demangle.cc: Remove.
2004-02-26 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/demangle.h: Add type template parameter to all
templates with just an Allocator template parameter.
2004-02-25 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/atomicity.h: New, forward declarations for __atomic_add

View File

@ -103,7 +103,6 @@ bits_headers = \
${bits_srcdir}/concept_check.h \
${bits_srcdir}/concurrence.h \
${bits_srcdir}/cpp_type_traits.h \
${bits_srcdir}/demangle.h \
${bits_srcdir}/deque.tcc \
${bits_srcdir}/fstream.tcc \
${bits_srcdir}/functexcept.h \
@ -204,6 +203,7 @@ ext_builddir = ./ext
ext_headers = \
${ext_srcdir}/algorithm \
${ext_srcdir}/debug_allocator.h \
${ext_srcdir}/demangle.h \
${ext_srcdir}/enc_filebuf.h \
${ext_srcdir}/stdio_filebuf.h \
${ext_srcdir}/stdio_sync_filebuf.h \

View File

@ -299,7 +299,6 @@ bits_headers = \
${bits_srcdir}/concept_check.h \
${bits_srcdir}/concurrence.h \
${bits_srcdir}/cpp_type_traits.h \
${bits_srcdir}/demangle.h \
${bits_srcdir}/deque.tcc \
${bits_srcdir}/fstream.tcc \
${bits_srcdir}/functexcept.h \
@ -402,6 +401,7 @@ ext_builddir = ./ext
ext_headers = \
${ext_srcdir}/algorithm \
${ext_srcdir}/debug_allocator.h \
${ext_srcdir}/demangle.h \
${ext_srcdir}/enc_filebuf.h \
${ext_srcdir}/stdio_filebuf.h \
${ext_srcdir}/stdio_sync_filebuf.h \
@ -526,9 +526,9 @@ debug_headers = \
# For --enable-cheaders=c_std
@GLIBCXX_C_HEADERS_C_STD_TRUE@c_base_headers_extra = ${c_base_srcdir}/cmath.tcc
@GLIBCXX_C_HEADERS_C_STD_FALSE@c_base_headers_extra =
@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra =
@GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = ${c_compatibility_headers}
@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra =
host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR)
host_builddir = ./${host_alias}/bits

View File

@ -1,6 +1,6 @@
// 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
@ -37,6 +37,7 @@
#include <vector>
#include <string>
#include <ext/new_allocator.h>
#ifndef _GLIBCXX_DEMANGLER_DEBUG
#define _GLIBCXX_DEMANGLER_CWDEBUG 0
@ -58,7 +59,6 @@ namespace __gnu_cxx
{
namespace demangler
{
enum substitution_nt
{
type,
@ -101,16 +101,16 @@ namespace __gnu_cxx
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
@ -205,7 +205,7 @@ namespace __gnu_cxx
#endif
};
template<typename Allocator>
template<typename Tp, typename Allocator>
class qualifier_list
{
typedef typename Allocator::template rebind<char>::other
@ -215,18 +215,18 @@ namespace __gnu_cxx
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)
{ }
@ -235,7 +235,7 @@ namespace __gnu_cxx
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
@ -244,7 +244,7 @@ namespace __gnu_cxx
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)); }
@ -254,7 +254,7 @@ namespace __gnu_cxx
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
@ -347,10 +347,11 @@ namespace __gnu_cxx
{ 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>
@ -406,7 +407,7 @@ namespace __gnu_cxx
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);
@ -449,7 +450,7 @@ namespace __gnu_cxx
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);
@ -465,10 +466,10 @@ namespace __gnu_cxx
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);
@ -476,12 +477,12 @@ namespace __gnu_cxx
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)
{
@ -572,9 +573,9 @@ namespace __gnu_cxx
// ::= 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();
@ -598,9 +599,9 @@ namespace __gnu_cxx
// <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')
@ -668,9 +669,9 @@ namespace __gnu_cxx
};
//
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;
@ -683,9 +684,9 @@ namespace __gnu_cxx
// <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;
@ -711,10 +712,10 @@ namespace __gnu_cxx
// 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;
@ -885,10 +886,10 @@ namespace __gnu_cxx
// <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')
@ -928,9 +929,9 @@ namespace __gnu_cxx
_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");
@ -988,9 +989,9 @@ namespace __gnu_cxx
_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'.
@ -1222,9 +1223,9 @@ namespace __gnu_cxx
{ "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");
@ -1292,9 +1293,9 @@ namespace __gnu_cxx
// ::= 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')
@ -1479,9 +1480,9 @@ namespace __gnu_cxx
// ::= 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')
@ -1542,9 +1543,9 @@ namespace __gnu_cxx
// 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)
@ -1702,9 +1703,9 @@ namespace __gnu_cxx
// 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
{
@ -1750,9 +1751,9 @@ namespace __gnu_cxx
_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
@ -1842,11 +1843,11 @@ namespace __gnu_cxx
}
//
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;
@ -1953,7 +1954,7 @@ namespace __gnu_cxx
++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,
@ -2209,9 +2210,9 @@ namespace __gnu_cxx
// ::= <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");
@ -2295,9 +2296,9 @@ namespace __gnu_cxx
// := 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)
@ -2327,9 +2328,9 @@ namespace __gnu_cxx
// <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';
@ -2359,9 +2360,9 @@ namespace __gnu_cxx
// ::= <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)
@ -2434,9 +2435,9 @@ namespace __gnu_cxx
// <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')
@ -2460,9 +2461,9 @@ namespace __gnu_cxx
//
// <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");
@ -2502,9 +2503,9 @@ namespace __gnu_cxx
//
// <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
@ -2557,9 +2558,9 @@ namespace __gnu_cxx
// 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')
@ -2642,9 +2643,9 @@ namespace __gnu_cxx
// 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
@ -2656,7 +2657,7 @@ namespace __gnu_cxx
#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);
@ -2696,7 +2697,7 @@ namespace __gnu_cxx
} // namespace demangler
// Public interface
template<typename Allocator>
template<typename Tp, typename Allocator>
struct demangle
{
typedef typename Allocator::template rebind<char>::other char_Allocator;
@ -2712,15 +2713,15 @@ namespace __gnu_cxx
//
// 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] != '_');
@ -2763,9 +2764,9 @@ namespace __gnu_cxx
// 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;
@ -2773,7 +2774,7 @@ namespace __gnu_cxx
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())
{
@ -2783,7 +2784,6 @@ namespace __gnu_cxx
}
return result;
}
} // namespace __gnu_cxx
#endif // __DEMANGLE_H

View File

@ -1,6 +1,6 @@
## Makefile for the GNU C++ Support library.
##
## Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
## Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
##
## Process this file with automake to produce Makefile.in.
##
@ -34,6 +34,9 @@ noinst_LTLIBRARIES = libsupc++convenience.la
headers = \
exception new typeinfo cxxabi.h exception_defines.h
c_sources = \
cp-demangle.c
sources = \
del_op.cc \
del_opnt.cc \
@ -62,8 +65,8 @@ sources = \
vec.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)
@ -83,6 +86,29 @@ AM_CXXFLAGS = \
AM_MAKEFLAGS = \
"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)
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 $<
# libstdc++ libtool notes
# 1) Need to explicitly set LTCXXCOMPILE so that AM_CXXFLAGS is

View File

@ -1,4 +1,4 @@
# 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
@ -42,7 +42,8 @@ ACLOCAL = @ACLOCAL@
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@
@ -227,6 +228,10 @@ headers = \
exception new typeinfo cxxabi.h exception_defines.h
c_sources = \
cp-demangle.c
sources = \
del_op.cc \
del_opnt.cc \
@ -256,8 +261,8 @@ sources = \
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)
@ -279,6 +284,21 @@ AM_MAKEFLAGS = \
"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
@ -329,16 +349,22 @@ am__objects_1 = del_op.lo del_opnt.lo del_opv.lo del_opvnt.lo \
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)
@ -353,7 +379,7 @@ SOURCES = $(libsupc___la_SOURCES) $(libsupc__convenience_la_SOURCES)
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
@ -407,6 +433,15 @@ mostlyclean-compile:
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)/'`$<
@ -530,7 +565,7 @@ install-am: all-am
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:
@ -606,6 +641,14 @@ uninstall-am: uninstall-glibcxxinstallHEADERS uninstall-info-am \
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)

View File

@ -101,7 +101,6 @@ sources = \
complex_io.cc \
ctype.cc \
debug.cc \
demangle.cc \
functexcept.cc \
globals_locale.cc \
globals_io.cc \

View File

@ -220,12 +220,12 @@ AM_CPPFLAGS = $(GLIBCXX_INCLUDES)
# Cross compiler support.
toolexeclib_LTLIBRARIES = libstdc++.la
@GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE@version_arg =
# Symbol versioning for shared libraries.
@GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@version_arg = -Wl,--version-script=libstdc++-symbol.ver
@GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE@version_arg =
@GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@version_dep = libstdc++-symbol.ver
@GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE@version_dep =
@GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@version_dep = libstdc++-symbol.ver
# Source files linked in via configuration/make substitution for a
# particular host.
@ -256,7 +256,6 @@ sources = \
complex_io.cc \
ctype.cc \
debug.cc \
demangle.cc \
functexcept.cc \
globals_locale.cc \
globals_io.cc \
@ -366,9 +365,9 @@ am__objects_1 = atomicity.lo codecvt_members.lo collate_members.lo \
numeric_members.lo time_members.lo
am__objects_2 = basic_file.lo c++locale.lo
am__objects_3 = allocator.lo codecvt.lo complex_io.lo ctype.lo debug.lo \
demangle.lo functexcept.lo globals_locale.lo globals_io.lo \
ios.lo ios_failure.lo ios_init.lo ios_locale.lo limits.lo \
list.lo locale.lo locale_init.lo locale_facets.lo localename.lo \
functexcept.lo globals_locale.lo globals_io.lo ios.lo \
ios_failure.lo ios_init.lo ios_locale.lo limits.lo list.lo \
locale.lo locale_init.lo locale_facets.lo localename.lo \
stdexcept.lo strstream.lo tree.lo allocator-inst.lo \
concept-inst.lo fstream-inst.lo ext-inst.lo io-inst.lo \
istream-inst.lo locale-inst.lo locale-misc-inst.lo misc-inst.lo \

View File

@ -1,195 +0,0 @@
// 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&);
}

View File

@ -31,7 +31,7 @@ int main()
// extern "C" function
// extern "C" float f(void) { };
// T f
verify_demangle("f", "f");
verify_demangle("f", "error code = -2: invalid mangled name");
return 0;
}

View File

@ -31,7 +31,7 @@ int main()
// or variable "f"
// int f;
// B f
verify_demangle("f", "f");
verify_demangle("f", "error code = -2: invalid mangled name");
return 0;
}

View File

@ -28,7 +28,8 @@ int main()
using namespace __gnu_test;
// cplus-dem CORE
verify_demangle("_X11TransParseAddress", "_X11TransParseAddress");
verify_demangle("_X11TransParseAddress",
"error code = -2: invalid mangled name");
return 0;
}

View File

@ -29,14 +29,14 @@ int main()
// 2003/11/07, libstdc++/12736
verify_demangle("_Z3fooIA6_KiEvA9_KT_rVPrS4_",
"void foo<int const [6]>(int const [9][6], int const restrict (* volatile restrict) [9][6])");
"void foo<int const [6]>(int const [9][6], int restrict const (* volatile restrict) [9][6])");
// 2003/11/12, libstdc++/12947
verify_demangle("_Z1fILi5E1AEvN1CIXqugtT_Li0ELi1ELi2EEE1qE",
"void f<5, A>(C<(((5) > (0))) ? (1) : (2)>::q)");
verify_demangle("_Z1fILi5EEvN1AIXcvimlT_Li22EEE1qE",
"void f<5>(A<(int)((5) * (22))>::q)");
verify_demangle("_Z1fPFYPFiiEiE",
"f(int (*(*) [extern \"C\"] (int))(int))");
"f(int (*(*)(int))(int))");
verify_demangle("_Z1fI1XENT_1tES2_",
"X::t f<X>(X::t)");
verify_demangle("_Z1fILi5E1AEvN1CIXstN1T1tEEXszsrS2_1tEE1qE",