cxxfilt: small changes from Apple's developer tools

From Apple's Developer Tools 4.0 [1]:

demangle.patch
2007-05-05  Geoffrey Keating
	(d_name): Detect local-source-name.
	(d_prefix): Likewise.
	(d_unqualified_name): Implement local-source-name.

libiberty-printf.patch

MFC after:	1 month

[1] http://opensource.apple.com/source/cxxfilt/cxxfilt-9/patches/
This commit is contained in:
Pedro F. Giffuni 2013-11-11 21:18:02 +00:00
parent 62f34c2aac
commit 0944614655
3 changed files with 75 additions and 3 deletions

View File

@ -63,12 +63,12 @@ demangle_it (char *mangled_name)
result = cplus_demangle (mangled_name + skip_first, flags);
if (result == NULL)
printf (mangled_name);
printf ("%s",mangled_name);
else
{
if (mangled_name[0] == '.')
putchar ('.');
printf (result);
printf ("%s",result);
free (result);
}
}

View File

@ -1054,6 +1054,11 @@ d_name (struct d_info *di)
case 'Z':
return d_local_name (di);
/* APPLE LOCAL begin mainline 2007-05-09 5173149 */ \
case 'L':
return d_unqualified_name (di);
/* APPLE LOCAL end mainline 2007-05-09 5173149 */ \
case 'S':
{
int subst;
@ -1174,7 +1179,10 @@ d_prefix (struct d_info *di)
if (IS_DIGIT (peek)
|| IS_LOWER (peek)
|| peek == 'C'
|| peek == 'D')
/* APPLE LOCAL begin mainline 2007-05-09 5173149 */ \
|| peek == 'D'
|| peek == 'L')
/* APPLE LOCAL end mainline 2007-05-09 5173149 */ \
dc = d_unqualified_name (di);
else if (peek == 'S')
dc = d_substitution (di, 1);
@ -1208,6 +1216,11 @@ d_prefix (struct d_info *di)
/* <unqualified-name> ::= <operator-name>
::= <ctor-dtor-name>
::= <source-name>
APPLE LOCAL begin mainline 2007-05-09 5173149
::= <local-source-name>
<local-source-name> ::= L <source-name> <discriminator>
APPLE LOCAL end mainline 2007-05-09 5173149
*/
static struct demangle_component *
@ -1229,6 +1242,21 @@ d_unqualified_name (struct d_info *di)
}
else if (peek == 'C' || peek == 'D')
return d_ctor_dtor_name (di);
/* APPLE LOCAL begin mainline 2007-05-09 5173149 */ \
else if (peek == 'L')
{
struct demangle_component * ret;
d_advance (di, 1);
ret = d_source_name (di);
if (ret == NULL)
return NULL;
if (! d_discriminator (di))
return NULL;
return ret;
}
/* APPLE LOCAL end mainline 2007-05-09 5173149 */ \
else
return NULL;
}

View File

@ -3816,3 +3816,47 @@ f
SASDASDFASDF_sdfsdf
SASDASDFASDF_sdfsdf
SASDASDFASDF_sdfsdf
# APPLE LOCAL begin mainline 2007-05-09 5173149
# These are all cases of invalid manglings where the demangler would read
# past the end of the string.
# d_name wasn't honouring a NULL from d_substitution
--format=gnu-v3
_ZSA
_ZSA
# d_expr_primary wasn't honouring NULL from cplus_demangle_mangled_name
--format=gnu-v3
_ZN1fIL_
_ZN1fIL_
# d_operator_name was taking two characters in a row
--format=gnu-v3
_Za
_Za
# d_prefix wasn't honouring NULL from d_substitution
--format=gnu-v3
_ZNSA
_ZNSA
# d_prefix wasn't honouring NULL from d_template_param
--format=gnu-v3
_ZNT
_ZNT
# Dereferencing NULL in d_pointer_to_member_type
--format=gnu-v3
_Z1aMark
_Z1aMark
# <local-source-name> test 1
--format=gnu-v3
_ZL3foo_2
foo
# <local-source-name> test 2
--format=gnu-v3
_ZZL3foo_2vE4var1
foo()::var1
# <local-source-name> test 3
--format=gnu-v3
_ZZL3foo_2vE4var1_0
foo()::var1
# <local-source-name> test 4
--format=gnu-v3
_ZZN7myspaceL3foo_1EvEN11localstruct1fEZNS_3fooEvE16otherlocalstruct
myspace::foo()::localstruct::f(myspace::foo()::otherlocalstruct)
# APPLE LOCAL end mainline 2007-05-09 5173149