aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2007-02-22 17:03:48 +0000
committerMichael Matz <matz@gcc.gnu.org>2007-02-22 17:03:48 +0000
commita0ad3539f415e3f925691340ce389c0dc0819c91 (patch)
treeb9429c7e1446e9672a2be1a81499cfcc7a228646 /gcc/cp/pt.c
parentb3502aa8d46d9cd008916170a635b2bf3a5d5125 (diff)
downloadgcc-a0ad3539f415e3f925691340ce389c0dc0819c91.zip
gcc-a0ad3539f415e3f925691340ce389c0dc0819c91.tar.gz
gcc-a0ad3539f415e3f925691340ce389c0dc0819c91.tar.bz2
dwarf2out.c (add_AT_string): Call ggc_strdup once per string.
* dwarf2out.c (add_AT_string): Call ggc_strdup once per string. (type_tag): Use lang_hooks.dwarf_name instead of DECL_NAME. * cp-tree.h (TFF_NO_OUTER_SCOPE): New formatting flag. * error.c (dump_aggr_type, dump_simple_decl, dump_decl, dump_function_decl): Guard emitting outer scopes by new flag. * cp-lang.c (cxx_dwarf_name): New function. (LANG_HOOKS_DWARF_NAME): Define to cxx_dwarf_name. * pt.c (classtype_mangled_name, mangle_class_name_for_template): Remove functions. (push_template_decl_real, lookup_template_class): Remove calls to above functions. From-SVN: r122230
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r--gcc/cp/pt.c133
1 files changed, 1 insertions, 132 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 31ad46c..8ade0a0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -106,8 +106,6 @@ static void add_pending_template (tree);
static int push_tinst_level (tree);
static void pop_tinst_level (void);
static void reopen_tinst_level (tree);
-static tree classtype_mangled_name (tree);
-static char* mangle_class_name_for_template (const char *, tree, tree);
static tree tsubst_initializer_list (tree, tree);
static tree get_class_bindings (tree, tree, tree);
static tree coerce_template_parms (tree, tree, tree, tsubst_flags_t,
@@ -3349,14 +3347,7 @@ push_template_decl_real (tree decl, bool is_friend)
info = tree_cons (tmpl, args, NULL_TREE);
if (DECL_IMPLICIT_TYPEDEF_P (decl))
- {
- SET_TYPE_TEMPLATE_INFO (TREE_TYPE (tmpl), info);
- if ((!ctx || TREE_CODE (ctx) != FUNCTION_DECL)
- && TREE_CODE (TREE_TYPE (decl)) != ENUMERAL_TYPE
- /* Don't change the name if we've already set it up. */
- && !IDENTIFIER_TEMPLATE (DECL_NAME (decl)))
- DECL_NAME (decl) = classtype_mangled_name (TREE_TYPE (decl));
- }
+ SET_TYPE_TEMPLATE_INFO (TREE_TYPE (tmpl), info);
else if (DECL_LANG_SPECIFIC (decl))
DECL_TEMPLATE_INFO (decl) = info;
@@ -4301,124 +4292,6 @@ comp_template_args (tree oldargs, tree newargs)
return 1;
}
-/* Given class template name and parameter list, produce a user-friendly name
- for the instantiation. */
-
-static char *
-mangle_class_name_for_template (const char* name, tree parms, tree arglist)
-{
- static struct obstack scratch_obstack;
- static char *scratch_firstobj;
- int i, nparms;
-
- if (!scratch_firstobj)
- gcc_obstack_init (&scratch_obstack);
- else
- obstack_free (&scratch_obstack, scratch_firstobj);
- scratch_firstobj = (char *) obstack_alloc (&scratch_obstack, 1);
-
-#define ccat(C) obstack_1grow (&scratch_obstack, (C));
-#define cat(S) obstack_grow (&scratch_obstack, (S), strlen (S))
-
- cat (name);
- ccat ('<');
- nparms = TREE_VEC_LENGTH (parms);
- arglist = INNERMOST_TEMPLATE_ARGS (arglist);
- gcc_assert (nparms == TREE_VEC_LENGTH (arglist));
- for (i = 0; i < nparms; i++)
- {
- tree parm;
- tree arg;
-
- parm = TREE_VALUE (TREE_VEC_ELT (parms, i));
- arg = TREE_VEC_ELT (arglist, i);
-
- if (parm == error_mark_node)
- continue;
-
- if (i)
- ccat (',');
-
- if (TREE_CODE (parm) == TYPE_DECL)
- {
- cat (type_as_string (arg, TFF_CHASE_TYPEDEF));
- continue;
- }
- else if (TREE_CODE (parm) == TEMPLATE_DECL)
- {
- if (TREE_CODE (arg) == TEMPLATE_DECL)
- {
- /* Already substituted with real template. Just output
- the template name here */
- tree context = DECL_CONTEXT (arg);
- if (context)
- {
- /* The template may be defined in a namespace, or
- may be a member template. */
- gcc_assert (TREE_CODE (context) == NAMESPACE_DECL
- || CLASS_TYPE_P (context));
- cat (decl_as_string (DECL_CONTEXT (arg),
- TFF_PLAIN_IDENTIFIER));
- cat ("::");
- }
- cat (IDENTIFIER_POINTER (DECL_NAME (arg)));
- }
- else
- /* Output the parameter declaration. */
- cat (type_as_string (arg, TFF_CHASE_TYPEDEF));
- continue;
- }
- else
- gcc_assert (TREE_CODE (parm) == PARM_DECL);
-
- /* No need to check arglist against parmlist here; we did that
- in coerce_template_parms, called from lookup_template_class. */
- cat (expr_as_string (arg, TFF_PLAIN_IDENTIFIER));
- }
- {
- char *bufp = obstack_next_free (&scratch_obstack);
- int offset = 0;
- while (bufp[offset - 1] == ' ')
- offset--;
- obstack_blank_fast (&scratch_obstack, offset);
-
- /* B<C<char> >, not B<C<char>> */
- if (bufp[offset - 1] == '>')
- ccat (' ');
- }
- ccat ('>');
- ccat ('\0');
- return (char *) obstack_base (&scratch_obstack);
-}
-
-static tree
-classtype_mangled_name (tree t)
-{
- if (CLASSTYPE_TEMPLATE_INFO (t)
- /* Specializations have already had their names set up in
- lookup_template_class. */
- && !CLASSTYPE_TEMPLATE_SPECIALIZATION (t))
- {
- tree tmpl = most_general_template (CLASSTYPE_TI_TEMPLATE (t));
-
- /* For non-primary templates, the template parameters are
- implicit from their surrounding context. */
- if (PRIMARY_TEMPLATE_P (tmpl))
- {
- tree name = DECL_NAME (tmpl);
- char *mangled_name = mangle_class_name_for_template
- (IDENTIFIER_POINTER (name),
- DECL_INNERMOST_TEMPLATE_PARMS (tmpl),
- CLASSTYPE_TI_ARGS (t));
- tree id = get_identifier (mangled_name);
- IDENTIFIER_TEMPLATE (id) = name;
- return id;
- }
- }
-
- return TYPE_IDENTIFIER (t);
-}
-
static void
add_pending_template (tree d)
{
@@ -4965,10 +4838,6 @@ lookup_template_class (tree d1,
the instantiation and exit above. */
tsubst_enum (template_type, t, arglist);
- /* Reset the name of the type, now that CLASSTYPE_TEMPLATE_INFO
- is set up. */
- if (TREE_CODE (t) != ENUMERAL_TYPE)
- DECL_NAME (type_decl) = classtype_mangled_name (t);
if (is_partial_instantiation)
/* If the type makes use of template parameters, the
code that generates debugging information will crash. */