cp-tree.h (mangle_type): Remove.

* cp-tree.h (mangle_type): Remove.
	* mangle.c (globals): GTY it.
	(mangle_obstack): New variable.
	(name_obstack): Likewise.
	(name_base): Likewise.
	(write_char): Adjust accordingly.
	(write_chars): Likewise.
	(write_string): Likewise.
	(start_mangling): Initialize G.substitutions only one.  Add
	ident_p parameter.
	(finish_mangling): Use VARRAY_CLEAR to reclaim
	storage in G.substitutions.  Use obstack_finish.
	(init_mangle): Adjust for changes to variable names above.
	Initialize G.substitutions.
	(mangle_decl_string): Adjust call to start_mangling.
	(get_identifier_nocopy): New function.
	(mangle_decl): Use it.
	(mangle_type_string): Adjust call to start_mangling.
	(mangle_special_for_type): Likewise.
	(mangle_vtt_for_type): Likewise.
	(mangle_ctor_vtbl_for_type): Likewise.
	(mangle_thunk): Likewise.
	(mangle_guard_variable): Likewise.
	(mangle_ref_init_variable): Likewise.

From-SVN: r86559
This commit is contained in:
Mark Mitchell 2004-08-25 16:58:23 +00:00 committed by Mark Mitchell
parent 40f201864f
commit 2b8fe4a03f
3 changed files with 86 additions and 40 deletions

View File

@ -1,3 +1,30 @@
2004-08-25 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (mangle_type): Remove.
* mangle.c (globals): GTY it.
(mangle_obstack): New variable.
(name_obstack): Likewise.
(name_base): Likewise.
(write_char): Adjust accordingly.
(write_chars): Likewise.
(write_string): Likewise.
(start_mangling): Initialize G.substitutions only one. Add
ident_p parameter.
(finish_mangling): Use VARRAY_CLEAR to reclaim
storage in G.substitutions. Use obstack_finish.
(init_mangle): Adjust for changes to variable names above.
Initialize G.substitutions.
(mangle_decl_string): Adjust call to start_mangling.
(get_identifier_nocopy): New function.
(mangle_decl): Use it.
(mangle_type_string): Adjust call to start_mangling.
(mangle_special_for_type): Likewise.
(mangle_vtt_for_type): Likewise.
(mangle_ctor_vtbl_for_type): Likewise.
(mangle_thunk): Likewise.
(mangle_guard_variable): Likewise.
(mangle_ref_init_variable): Likewise.
2004-08-25 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/14428

View File

@ -4358,7 +4358,6 @@ extern tree merge_exception_specifiers (tree, tree);
extern void init_mangle (void);
extern void mangle_decl (tree);
extern const char *mangle_type_string (tree);
extern tree mangle_type (tree);
extern tree mangle_typeinfo_for_type (tree);
extern tree mangle_typeinfo_string_for_type (tree);
extern tree mangle_vtbl_for_type (tree);

View File

@ -92,22 +92,32 @@
&& (PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (NODE))))))
/* Things we only need one of. This module is not reentrant. */
static struct globals
typedef struct globals GTY(())
{
/* The name in which we're building the mangled name. */
struct obstack name_obstack;
/* An array of the current substitution candidates, in the order
we've seen them. */
varray_type substitutions;
/* The entity that is being mangled. */
tree entity;
tree GTY ((skip)) entity;
/* True if the mangling will be different in a future version of the
ABI. */
bool need_abi_warning;
} G;
} globals;
static GTY (()) globals G;
/* The obstack on which we build mangled names. */
static struct obstack *mangle_obstack;
/* The obstack on which we build mangled names that are not going to
be IDENTIFIER_NODEs. */
static struct obstack name_obstack;
/* The first object on the name_obstack; we use this to free memory
allocated on the name_obstack. */
static void *name_base;
/* Indices into subst_identifiers. These are identifiers used in
special substitution rules. */
@ -206,7 +216,7 @@ static const char *mangle_decl_string (const tree);
/* Control functions. */
static inline void start_mangling (const tree);
static inline void start_mangling (const tree, bool);
static inline const char *finish_mangling (const bool);
static tree mangle_special_for_type (const tree, const char *);
@ -217,16 +227,16 @@ static void write_java_integer_type_codes (const tree);
/* Append a single character to the end of the mangled
representation. */
#define write_char(CHAR) \
obstack_1grow (&G.name_obstack, (CHAR))
obstack_1grow (mangle_obstack, (CHAR))
/* Append a sized buffer to the end of the mangled representation. */
#define write_chars(CHAR, LEN) \
obstack_grow (&G.name_obstack, (CHAR), (LEN))
obstack_grow (mangle_obstack, (CHAR), (LEN))
/* Append a NUL-terminated string to the end of the mangled
representation. */
#define write_string(STRING) \
obstack_grow (&G.name_obstack, (STRING), strlen (STRING))
obstack_grow (mangle_obstack, (STRING), strlen (STRING))
/* Nonzero if NODE1 and NODE2 are both TREE_LIST nodes and have the
same purpose (context, which may be a type) and value (template
@ -2401,12 +2411,18 @@ write_substitution (const int seq_id)
/* Start mangling ENTITY. */
static inline void
start_mangling (const tree entity)
start_mangling (const tree entity, const bool ident_p)
{
G.entity = entity;
G.need_abi_warning = false;
VARRAY_TREE_INIT (G.substitutions, 1, "mangling substitutions");
obstack_free (&G.name_obstack, obstack_base (&G.name_obstack));
if (!ident_p)
{
obstack_free (&name_obstack, name_base);
mangle_obstack = &name_obstack;
name_base = obstack_alloc (&name_obstack, 0);
}
else
mangle_obstack = &ident_hash->stack;
}
/* Done with mangling. Return the generated mangled name. If WARN is
@ -2422,12 +2438,12 @@ finish_mangling (const bool warn)
G.entity);
/* Clear all the substitutions. */
G.substitutions = 0;
VARRAY_CLEAR (G.substitutions);
/* Null-terminate the string. */
write_char ('\0');
return (const char *) obstack_base (&G.name_obstack);
return (const char *) obstack_finish (mangle_obstack);
}
/* Initialize data structures for mangling. */
@ -2435,7 +2451,9 @@ finish_mangling (const bool warn)
void
init_mangle (void)
{
gcc_obstack_init (&G.name_obstack);
gcc_obstack_init (&name_obstack);
name_base = obstack_alloc (&name_obstack, 0);
VARRAY_TREE_INIT (G.substitutions, 1, "mangling substitutions");
/* Cache these identifiers for quick comparison when checking for
standard substitutions. */
@ -2454,7 +2472,7 @@ mangle_decl_string (const tree decl)
{
const char *result;
start_mangling (decl);
start_mangling (decl, /*ident_p=*/true);
if (TREE_CODE (decl) == TYPE_DECL)
write_type (TREE_TYPE (decl));
@ -2467,14 +2485,24 @@ mangle_decl_string (const tree decl)
return result;
}
/* Like get_identifier, except that NAME is assumed to have been
allocated on the obstack used by the identifier hash table. */
static inline tree
get_identifier_nocopy (const char *name)
{
hashnode ht_node = ht_lookup (ident_hash, name,
strlen (name), HT_ALLOCED);
return HT_IDENT_TO_GCC_IDENT (ht_node);
}
/* Create an identifier for the external mangled name of DECL. */
void
mangle_decl (const tree decl)
{
tree id = get_identifier (mangle_decl_string (decl));
SET_DECL_ASSEMBLER_NAME (decl, id);
SET_DECL_ASSEMBLER_NAME (decl,
get_identifier_nocopy (mangle_decl_string (decl)));
}
/* Generate the mangled representation of TYPE. */
@ -2484,7 +2512,7 @@ mangle_type_string (const tree type)
{
const char *result;
start_mangling (type);
start_mangling (type, /*ident_p=*/false);
write_type (type);
result = finish_mangling (/*warn=*/false);
if (DEBUG_MANGLE)
@ -2492,14 +2520,6 @@ mangle_type_string (const tree type)
return result;
}
/* Create an identifier for the mangled representation of TYPE. */
tree
mangle_type (const tree type)
{
return get_identifier (mangle_type_string (type));
}
/* Create an identifier for the mangled name of a special component
for belonging to TYPE. CODE is the ABI-specified code for this
component. */
@ -2511,7 +2531,7 @@ mangle_special_for_type (const tree type, const char *code)
/* We don't have an actual decl here for the special component, so
we can't just process the <encoded-name>. Instead, fake it. */
start_mangling (type);
start_mangling (type, /*ident_p=*/true);
/* Start the mangling. */
write_string ("_Z");
@ -2524,7 +2544,7 @@ mangle_special_for_type (const tree type, const char *code)
if (DEBUG_MANGLE)
fprintf (stderr, "mangle_special_for_type = %s\n\n", result);
return get_identifier (result);
return get_identifier_nocopy (result);
}
/* Create an identifier for the mangled representation of the typeinfo
@ -2580,7 +2600,7 @@ mangle_ctor_vtbl_for_type (const tree type, const tree binfo)
{
const char *result;
start_mangling (type);
start_mangling (type, /*ident_p=*/true);
write_string ("_Z");
write_string ("TC");
@ -2592,7 +2612,7 @@ mangle_ctor_vtbl_for_type (const tree type, const tree binfo)
result = finish_mangling (/*warn=*/false);
if (DEBUG_MANGLE)
fprintf (stderr, "mangle_ctor_vtbl_for_type = %s\n\n", result);
return get_identifier (result);
return get_identifier_nocopy (result);
}
/* Mangle a this pointer or result pointer adjustment.
@ -2637,7 +2657,7 @@ mangle_thunk (tree fn_decl, const int this_adjusting, tree fixed_offset,
{
const char *result;
start_mangling (fn_decl);
start_mangling (fn_decl, /*ident_p=*/true);
write_string ("_Z");
write_char ('T');
@ -2671,7 +2691,7 @@ mangle_thunk (tree fn_decl, const int this_adjusting, tree fixed_offset,
result = finish_mangling (/*warn=*/false);
if (DEBUG_MANGLE)
fprintf (stderr, "mangle_thunk = %s\n\n", result);
return get_identifier (result);
return get_identifier_nocopy (result);
}
/* This hash table maps TYPEs to the IDENTIFIER for a conversion
@ -2740,7 +2760,7 @@ mangle_conv_op_name_for_type (const tree type)
tree
mangle_guard_variable (const tree variable)
{
start_mangling (variable);
start_mangling (variable, /*ident_p=*/true);
write_string ("_ZGV");
if (strncmp (IDENTIFIER_POINTER (DECL_NAME (variable)), "_ZGR", 4) == 0)
/* The name of a guard variable for a reference temporary should refer
@ -2748,7 +2768,7 @@ mangle_guard_variable (const tree variable)
write_string (IDENTIFIER_POINTER (DECL_NAME (variable)) + 4);
else
write_name (variable, /*ignore_local_scope=*/0);
return get_identifier (finish_mangling (/*warn=*/false));
return get_identifier_nocopy (finish_mangling (/*warn=*/false));
}
/* Return an identifier for the name of a temporary variable used to
@ -2758,10 +2778,10 @@ mangle_guard_variable (const tree variable)
tree
mangle_ref_init_variable (const tree variable)
{
start_mangling (variable);
start_mangling (variable, /*ident_p=*/true);
write_string ("_ZGR");
write_name (variable, /*ignore_local_scope=*/0);
return get_identifier (finish_mangling (/*warn=*/false));
return get_identifier_nocopy (finish_mangling (/*warn=*/false));
}