Commit 31058ee3 by Ian Lance Taylor Committed by Ian Lance Taylor

cp-demangle.h (enum d_builtin_type_print): Add D_PRINT_UNSIGNED...

	* cp-demangle.h (enum d_builtin_type_print): Add D_PRINT_UNSIGNED,
	D_PRINT_UNSIGNED_LONG, D_PRINT_LONG_LONG,
	D_PRINT_UNSIGNED_LONG_LONG, D_PRINT_FLOAT.
	* cp-demangle.c (cplus_demangle_builtin_types): Change char and
	short types to D_PRINT_DEFAULT.  Change other integer types to use
	new D_PRINT_* values where appropriate.  Change float types to
	D_PRINT_FLOAT.
	(d_print_comp) [LITERAL, LITERAL_NEG]: Handle new D_PRINT_*
	values.
	* testsuite/demangle-expected: Adjust two test cases.

	* cp-demangle.c (d_print_function_type): Print a space before the
	parenthesis around the function type in more cases.
	* testsuite/demangle-expected: Adjust one test case.

From-SVN: r78421
parent 93f20626
2004-02-24 Ian Lance Taylor <ian@wasabisystems.com> 2004-02-24 Ian Lance Taylor <ian@wasabisystems.com>
* cp-demangle.h (enum d_builtin_type_print): Add D_PRINT_UNSIGNED,
D_PRINT_UNSIGNED_LONG, D_PRINT_LONG_LONG,
D_PRINT_UNSIGNED_LONG_LONG, D_PRINT_FLOAT.
* cp-demangle.c (cplus_demangle_builtin_types): Change char and
short types to D_PRINT_DEFAULT. Change other integer types to use
new D_PRINT_* values where appropriate. Change float types to
D_PRINT_FLOAT.
(d_print_comp) [LITERAL, LITERAL_NEG]: Handle new D_PRINT_*
values.
* testsuite/demangle-expected: Adjust two test cases.
* cp-demangle.c (d_print_function_type): Print a space before the
parenthesis around the function type in more cases.
* testsuite/demangle-expected: Adjust one test case.
* cp-demangle.c (d_print_comp) [UNARY]: Don't emit extra * cp-demangle.c (d_print_comp) [UNARY]: Don't emit extra
parentheses around a cast. parentheses around a cast.
* testsuite/demangle-expected: Adjust two test cases to match new * testsuite/demangle-expected: Adjust two test cases to match new
......
...@@ -1748,31 +1748,33 @@ CP_STATIC_IF_GLIBCPP_V3 ...@@ -1748,31 +1748,33 @@ CP_STATIC_IF_GLIBCPP_V3
const struct demangle_builtin_type_info const struct demangle_builtin_type_info
cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT] = cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT] =
{ {
/* a */ { NL ("signed char"), NL ("signed char"), D_PRINT_INT }, /* a */ { NL ("signed char"), NL ("signed char"), D_PRINT_DEFAULT },
/* b */ { NL ("bool"), NL ("boolean"), D_PRINT_BOOL }, /* b */ { NL ("bool"), NL ("boolean"), D_PRINT_BOOL },
/* c */ { NL ("char"), NL ("byte"), D_PRINT_INT }, /* c */ { NL ("char"), NL ("byte"), D_PRINT_DEFAULT },
/* d */ { NL ("double"), NL ("double"), D_PRINT_DEFAULT }, /* d */ { NL ("double"), NL ("double"), D_PRINT_FLOAT },
/* e */ { NL ("long double"), NL ("long double"), D_PRINT_DEFAULT }, /* e */ { NL ("long double"), NL ("long double"), D_PRINT_FLOAT },
/* f */ { NL ("float"), NL ("float"), D_PRINT_DEFAULT }, /* f */ { NL ("float"), NL ("float"), D_PRINT_FLOAT },
/* g */ { NL ("__float128"), NL ("__float128"), D_PRINT_DEFAULT }, /* g */ { NL ("__float128"), NL ("__float128"), D_PRINT_FLOAT },
/* h */ { NL ("unsigned char"), NL ("unsigned char"), D_PRINT_INT }, /* h */ { NL ("unsigned char"), NL ("unsigned char"), D_PRINT_DEFAULT },
/* i */ { NL ("int"), NL ("int"), D_PRINT_INT }, /* i */ { NL ("int"), NL ("int"), D_PRINT_INT },
/* j */ { NL ("unsigned int"), NL ("unsigned"), D_PRINT_INT }, /* j */ { NL ("unsigned int"), NL ("unsigned"), D_PRINT_UNSIGNED },
/* k */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* k */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT },
/* l */ { NL ("long"), NL ("long"), D_PRINT_LONG }, /* l */ { NL ("long"), NL ("long"), D_PRINT_LONG },
/* m */ { NL ("unsigned long"), NL ("unsigned long"), D_PRINT_LONG }, /* m */ { NL ("unsigned long"), NL ("unsigned long"), D_PRINT_UNSIGNED_LONG },
/* n */ { NL ("__int128"), NL ("__int128"), D_PRINT_DEFAULT }, /* n */ { NL ("__int128"), NL ("__int128"), D_PRINT_DEFAULT },
/* o */ { NL ("unsigned __int128"), NL ("unsigned __int128"), D_PRINT_DEFAULT }, /* o */ { NL ("unsigned __int128"), NL ("unsigned __int128"),
D_PRINT_DEFAULT },
/* p */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* p */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT },
/* q */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* q */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT },
/* r */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* r */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT },
/* s */ { NL ("short"), NL ("short"), D_PRINT_INT }, /* s */ { NL ("short"), NL ("short"), D_PRINT_DEFAULT },
/* t */ { NL ("unsigned short"), NL ("unsigned short"), D_PRINT_INT }, /* t */ { NL ("unsigned short"), NL ("unsigned short"), D_PRINT_DEFAULT },
/* u */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* u */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT },
/* v */ { NL ("void"), NL ("void"), D_PRINT_VOID }, /* v */ { NL ("void"), NL ("void"), D_PRINT_VOID },
/* w */ { NL ("wchar_t"), NL ("char"), D_PRINT_INT }, /* w */ { NL ("wchar_t"), NL ("char"), D_PRINT_DEFAULT },
/* x */ { NL ("long long"), NL ("long"), D_PRINT_DEFAULT }, /* x */ { NL ("long long"), NL ("long"), D_PRINT_LONG_LONG },
/* y */ { NL ("unsigned long long"), NL ("unsigned long long"), D_PRINT_DEFAULT }, /* y */ { NL ("unsigned long long"), NL ("unsigned long long"),
D_PRINT_UNSIGNED_LONG_LONG },
/* z */ { NL ("..."), NL ("..."), D_PRINT_DEFAULT }, /* z */ { NL ("..."), NL ("..."), D_PRINT_DEFAULT },
}; };
...@@ -3347,62 +3349,86 @@ d_print_comp (dpi, dc) ...@@ -3347,62 +3349,86 @@ d_print_comp (dpi, dc)
case DEMANGLE_COMPONENT_LITERAL: case DEMANGLE_COMPONENT_LITERAL:
case DEMANGLE_COMPONENT_LITERAL_NEG: case DEMANGLE_COMPONENT_LITERAL_NEG:
/* For some builtin types, produce simpler output. */ {
if (d_left (dc)->type == DEMANGLE_COMPONENT_BUILTIN_TYPE) enum d_builtin_type_print tp;
{
switch (d_left (dc)->u.s_builtin.type->print)
{
case D_PRINT_INT:
if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME)
{
if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
d_append_char (dpi, '-');
d_print_comp (dpi, d_right (dc));
return;
}
break;
case D_PRINT_LONG: /* For some builtin types, produce simpler output. */
if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME) tp = D_PRINT_DEFAULT;
{ if (d_left (dc)->type == DEMANGLE_COMPONENT_BUILTIN_TYPE)
if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) {
d_append_char (dpi, '-'); tp = d_left (dc)->u.s_builtin.type->print;
d_print_comp (dpi, d_right (dc)); switch (tp)
d_append_char (dpi, 'l'); {
return; case D_PRINT_INT:
} case D_PRINT_UNSIGNED:
break; case D_PRINT_LONG:
case D_PRINT_UNSIGNED_LONG:
case D_PRINT_LONG_LONG:
case D_PRINT_UNSIGNED_LONG_LONG:
if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME)
{
if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
d_append_char (dpi, '-');
d_print_comp (dpi, d_right (dc));
switch (tp)
{
default:
break;
case D_PRINT_UNSIGNED:
d_append_char (dpi, 'u');
break;
case D_PRINT_LONG:
d_append_char (dpi, 'l');
break;
case D_PRINT_UNSIGNED_LONG:
d_append_string_constant (dpi, "ul");
break;
case D_PRINT_LONG_LONG:
d_append_string_constant (dpi, "ll");
break;
case D_PRINT_UNSIGNED_LONG_LONG:
d_append_string_constant (dpi, "ull");
break;
}
return;
}
break;
case D_PRINT_BOOL: case D_PRINT_BOOL:
if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME
&& d_right (dc)->u.s_name.len == 1 && d_right (dc)->u.s_name.len == 1
&& dc->type == DEMANGLE_COMPONENT_LITERAL) && dc->type == DEMANGLE_COMPONENT_LITERAL)
{ {
switch (d_right (dc)->u.s_name.s[0]) switch (d_right (dc)->u.s_name.s[0])
{ {
case '0': case '0':
d_append_string_constant (dpi, "false"); d_append_string_constant (dpi, "false");
return; return;
case '1': case '1':
d_append_string_constant (dpi, "true"); d_append_string_constant (dpi, "true");
return; return;
default: default:
break; break;
} }
} }
break; break;
default: default:
break; break;
} }
} }
d_append_char (dpi, '('); d_append_char (dpi, '(');
d_print_comp (dpi, d_left (dc)); d_print_comp (dpi, d_left (dc));
d_append_char (dpi, ')'); d_append_char (dpi, ')');
if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG)
d_append_char (dpi, '-'); d_append_char (dpi, '-');
d_print_comp (dpi, d_right (dc)); if (tp == D_PRINT_FLOAT)
d_append_char (dpi, '[');
d_print_comp (dpi, d_right (dc));
if (tp == D_PRINT_FLOAT)
d_append_char (dpi, ']');
}
return; return;
default: default:
...@@ -3612,11 +3638,13 @@ d_print_function_type (dpi, dc, mods) ...@@ -3612,11 +3638,13 @@ d_print_function_type (dpi, dc, mods)
{ {
int need_paren; int need_paren;
int saw_mod; int saw_mod;
int need_space;
struct d_print_mod *p; struct d_print_mod *p;
struct d_print_mod *hold_modifiers; struct d_print_mod *hold_modifiers;
need_paren = 0; need_paren = 0;
saw_mod = 0; saw_mod = 0;
need_space = 0;
for (p = mods; p != NULL; p = p->next) for (p = mods; p != NULL; p = p->next)
{ {
if (p->printed) if (p->printed)
...@@ -3625,15 +3653,18 @@ d_print_function_type (dpi, dc, mods) ...@@ -3625,15 +3653,18 @@ d_print_function_type (dpi, dc, mods)
saw_mod = 1; saw_mod = 1;
switch (p->mod->type) switch (p->mod->type)
{ {
case DEMANGLE_COMPONENT_POINTER:
case DEMANGLE_COMPONENT_REFERENCE:
need_paren = 1;
break;
case DEMANGLE_COMPONENT_RESTRICT: case DEMANGLE_COMPONENT_RESTRICT:
case DEMANGLE_COMPONENT_VOLATILE: case DEMANGLE_COMPONENT_VOLATILE:
case DEMANGLE_COMPONENT_CONST: case DEMANGLE_COMPONENT_CONST:
case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:
case DEMANGLE_COMPONENT_POINTER:
case DEMANGLE_COMPONENT_REFERENCE:
case DEMANGLE_COMPONENT_COMPLEX: case DEMANGLE_COMPONENT_COMPLEX:
case DEMANGLE_COMPONENT_IMAGINARY: case DEMANGLE_COMPONENT_IMAGINARY:
case DEMANGLE_COMPONENT_PTRMEM_TYPE: case DEMANGLE_COMPONENT_PTRMEM_TYPE:
need_space = 1;
need_paren = 1; need_paren = 1;
break; break;
case DEMANGLE_COMPONENT_RESTRICT_THIS: case DEMANGLE_COMPONENT_RESTRICT_THIS:
...@@ -3652,18 +3683,14 @@ d_print_function_type (dpi, dc, mods) ...@@ -3652,18 +3683,14 @@ d_print_function_type (dpi, dc, mods)
if (need_paren) if (need_paren)
{ {
switch (d_last_char (dpi)) if (! need_space)
{ {
case ' ': if (d_last_char (dpi) != '('
case '(': && d_last_char (dpi) != '*')
case '*': need_space = 1;
break;
default:
d_append_char (dpi, ' ');
break;
} }
if (need_space && d_last_char (dpi) != ' ')
d_append_char (dpi, ' ');
d_append_char (dpi, '('); d_append_char (dpi, '(');
} }
......
...@@ -53,10 +53,20 @@ enum d_builtin_type_print ...@@ -53,10 +53,20 @@ enum d_builtin_type_print
D_PRINT_DEFAULT, D_PRINT_DEFAULT,
/* Print as integer. */ /* Print as integer. */
D_PRINT_INT, D_PRINT_INT,
/* Print as long, with trailing `l'. */ /* Print as unsigned integer, with trailing "u". */
D_PRINT_UNSIGNED,
/* Print as long, with trailing "l". */
D_PRINT_LONG, D_PRINT_LONG,
/* Print as unsigned long, with trailing "ul". */
D_PRINT_UNSIGNED_LONG,
/* Print as long long, with trailing "ll". */
D_PRINT_LONG_LONG,
/* Print as unsigned long long, with trailing "ull". */
D_PRINT_UNSIGNED_LONG_LONG,
/* Print as bool. */ /* Print as bool. */
D_PRINT_BOOL, D_PRINT_BOOL,
/* Print as float--put value in square brackets. */
D_PRINT_FLOAT,
/* Print in usual way, but here to detect void. */ /* Print in usual way, but here to detect void. */
D_PRINT_VOID D_PRINT_VOID
}; };
......
...@@ -3591,13 +3591,13 @@ hairyfunc5 ...@@ -3591,13 +3591,13 @@ hairyfunc5
# This is from gcc PR 8861 # This is from gcc PR 8861
--format=gnu-v3 --no-params --format=gnu-v3 --no-params
_Z1fILi1ELc120EEv1AIXplT_cviLd810000000000000000703DAD7A370C5EEE _Z1fILi1ELc120EEv1AIXplT_cviLd810000000000000000703DAD7A370C5EEE
void f<1, 120>(A<(1) + ((int)((double)810000000000000000703DAD7A370C5))>) void f<1, (char)120>(A<(1) + ((int)((double)[810000000000000000703DAD7A370C5]))>)
f<1, 120> f<1, (char)120>
# #
# This is also from gcc PR 8861 # This is also from gcc PR 8861
--format=gnu-v3 --no-params --format=gnu-v3 --no-params
_Z1fILi1EEv1AIXplT_cvingLf3f800000EEE _Z1fILi1EEv1AIXplT_cvingLf3f800000EEE
void f<1>(A<(1) + ((int)(-((float)3f800000)))>) void f<1>(A<(1) + ((int)(-((float)[3f800000])))>)
f<1> f<1>
# #
# This is from a libstdc++ debug mode patch. # This is from a libstdc++ debug mode patch.
...@@ -3635,7 +3635,7 @@ std::operator< <file_path, std::string> ...@@ -3635,7 +3635,7 @@ std::operator< <file_path, std::string>
# More hairy qualifier handling. # More hairy qualifier handling.
--format=gnu-v3 --no-params --format=gnu-v3 --no-params
_Z9hairyfuncM1YKFPVPFrPA2_PM1XKFKPA3_ilEPcEiE _Z9hairyfuncM1YKFPVPFrPA2_PM1XKFKPA3_ilEPcEiE
hairyfunc(int (* const (X::** (* restrict (* volatile*(Y::*)(int) const)(char*)) [2])(long) const) [3]) hairyfunc(int (* const (X::** (* restrict (* volatile* (Y::*)(int) const)(char*)) [2])(long) const) [3])
hairyfunc hairyfunc
# #
# Check that negative numbers are handled correctly. # Check that negative numbers are handled correctly.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment