diff options
author | Mark Mitchell <mark@codesourcery.com> | 2001-03-19 23:50:04 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2001-03-19 23:50:04 +0000 |
commit | 92643fea9381b2d137f19d19e28e24a61dc44b0c (patch) | |
tree | 0e001bd33ab3dcdd688aa773f49f4ddf63c89df6 /gcc/cp/pt.c | |
parent | b90f4049d36e101e2090dd2c1a0595bdb3790ec2 (diff) | |
download | gcc-92643fea9381b2d137f19d19e28e24a61dc44b0c.zip gcc-92643fea9381b2d137f19d19e28e24a61dc44b0c.tar.gz gcc-92643fea9381b2d137f19d19e28e24a61dc44b0c.tar.bz2 |
Compute DECL_ASSEMBLER_NAME lazily.
* tree.h (DECL_ASSEMBLER_NAME): Compute it lazily.
(DECL_ASSEMBLER_NAME_SET_P): New macro.
(SET_DECL_ASSEMBLER_NAME): Likewise.
(COPY_DECL_ASSEMBLER_NAME): Likewise.
(set_decl_assembler_name): Declare.
(lang_set_decl_assembler_name): Likewise.
* tree.c (lang_set_decl_assembler_name): New variab.e
(set_decl_assembler_name): New function.
(init_obstacks): Set lang_set_decl_assembler_name.
(build_decl): Don't set DECL_ASSEMBLER_NAME.
* c-decl.c (duplicate_decls): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(builtin_function): Likewise.
(finish_decl): Likewise.
* dbxout.c (dbxout_type_methods): Likewise.
* ggc-common.c (ggc_mark_trees): Likewise.
* profile.c (output_func_start_profiler): Likewise.
* varasm.c (make_decl_rtl): Likewise.
* class.c (get_vtable_decl): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(add_method): Remove optimization involving comparison of
DECL_ASSEMBLER_NAME.
(build_vtbl_or_vbase_field): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(check_methods): Likewise.
(build_clone): Likewise.
(built_vtt): Likewise.
* cp-tree.h (DECL_NEEDED_P): Likewise.
* decl.c (pushtag): Likewise.
(duplicate_decls): Likewise.
(pushdecl): Likewise.
(builtin_function): Likewise.
(build_library_fn_1): Set DECL_LANGUAGE for library functions.
(build_cp_library_fn): Likewise.
(maybe_commonize_var): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(make_rtl_for_nonlocal_decl): Likewise.
(cp_finish_decl): Likewise.
(grokfndecl): Likewise.
(grokvardecl): Likewise.
(grokdeclarator): Likewise.
(start_function): Likewise.
(cp_missing_return_ok_p): Likewise.
* decl2.c (grokclassfn): Likewise.
(check_classfn): Likewise.
(finish_static_data_member_decl): Likewise.
(grokfield): Likewise.
* error.c (GLOBAL_IORD_P): Remove.
(dump_global_iord): Improve output.
(dump_decl): Avoid using DECL_ASSEMBLER_NAME.
* except.c (nothrow_libfn_p): Summarily reject any function not in
namespace-scope.
* init.c (build_java_class_ref): Don't explicitly set
DECL_ASSEMBLER_NAME after calling mangle_decl.
* mangle.c (mangle_decl_string): Handle extern "C" functions.
(mangle_decl): Set the DECL_ASSEMBLER_NAME for the decl.
* method.c (set_mangled_name_for_decl): Don't explicitly set
DECL_ASSEMBLER_NAME after calling mangle_decl.
(make_thunk): Explicitly set the DECL_ASSEMBLER_NAME and
IDENTIFIER_GLOBAL_VALUE for the thunk.
* pt.c (set_mangled_name_for_template_decl): Remove.
(check_explicit_specialization): Don't use it.
(looup_template_class): Don't set DECL_ASSEMBLER_NAME.
(tsubst_friend_function): Likewise.
(tsubst_decl): Likewise.
(regenerate_decl_from_template): Use COPY_DECL_ASSEMBLER_NAME.
* rtti.c (get_tinfo_decl): Use SET_DECL_ASSEMBLER_NAME,
COPY_DECL_ASSEMBLER_NAME, etc. Don't set DECL_ASSEMBLER_NAME
where it's not necessary.
(tinfo_base_init): Likewise.
(create_real_tinfo_var): Likewise.
* search.c (looup_field_1): Likewise.
* semantics.c (finish_named_return_value): Likewise.
* tree.c (init_tree): Set lang_set_decl_assembler_name.
* com.c (builtin_function): Use SET_DECL_ASSEMBLER_NAME.
* class.c (build_class_ref): Use SET_DECL_ASSEMBLER_NAME.
(layout_class): Likewise.
(layout_class_method): Likewise.
(emit_register_classes): Likewise.
* decl.c (builtin_function): Likewise.
(give_name_to_locals): Likewise.
From-SVN: r40642
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 96 |
1 files changed, 15 insertions, 81 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3fa1cde..1644f73 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -144,7 +144,6 @@ static tree tsubst_template_parms PARAMS ((tree, tree, int)); static void regenerate_decl_from_template PARAMS ((tree, tree)); static tree most_specialized PARAMS ((tree, tree, tree)); static tree most_specialized_class PARAMS ((tree, tree)); -static void set_mangled_name_for_template_decl PARAMS ((tree)); static int template_class_depth_real PARAMS ((tree, int)); static tree tsubst_aggr_type PARAMS ((tree, tree, int, tree, int)); static tree tsubst_decl PARAMS ((tree, tree, tree)); @@ -1678,24 +1677,6 @@ check_explicit_specialization (declarator, decl, template_count, flags) TREE_PRIVATE (decl) = TREE_PRIVATE (gen_tmpl); TREE_PROTECTED (decl) = TREE_PROTECTED (gen_tmpl); - /* Mangle the function name appropriately. Note that we do - not mangle specializations of non-template member - functions of template classes, e.g. with - - template <class T> struct S { void f(); } - - and given the specialization - - template <> void S<int>::f() {} - - we do not mangle S<int>::f() here. That's because it's - just an ordinary member function and doesn't need special - treatment. We do this here so that the ordinary, - non-template, name-mangling algorithm will not be used - later. */ - if (is_member_template (tmpl) || ctype == NULL_TREE) - set_mangled_name_for_template_decl (decl); - if (is_friend && !have_def) /* This is not really a declaration of a specialization. It's just the name of an instantiation. But, it's not @@ -4220,11 +4201,8 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope, complain) is set up. */ if (TREE_CODE (t) != ENUMERAL_TYPE) DECL_NAME (type_decl) = classtype_mangled_name (t); - DECL_ASSEMBLER_NAME (type_decl) = DECL_NAME (type_decl); if (!is_partial_instantiation) { - DECL_ASSEMBLER_NAME (type_decl) = mangle_decl (type_decl); - /* For backwards compatibility; code that uses -fexternal-templates expects looking up a template to instantiate it. I think DDD still relies on this. @@ -4606,18 +4584,14 @@ tsubst_friend_function (decl, args) = DECL_SAVED_TREE (DECL_TEMPLATE_RESULT (decl)); } - /* The mangled name for the NEW_FRIEND is incorrect. The call to - tsubst will have resulted in a call to - set_mangled_name_for_template_decl. But, the function is not a - template instantiation and should not be mangled like one. - Therefore, we remangle the function name. We don't have to do - this if the NEW_FRIEND is a template since - set_mangled_name_for_template_decl doesn't do anything if the - function declaration still uses template arguments. */ + /* The mangled name for the NEW_FRIEND is incorrect. The function + is not a template instantiation and should not be mangled like + one. Therefore, we forget the mangling here; we'll recompute it + later if we need it. */ if (TREE_CODE (new_friend) != TEMPLATE_DECL) { - set_mangled_name_for_decl (new_friend); SET_DECL_RTL (new_friend, NULL_RTX); + SET_DECL_ASSEMBLER_NAME (new_friend, NULL_TREE); } if (DECL_NAMESPACE_SCOPE_P (new_friend)) @@ -5805,6 +5779,9 @@ tsubst_decl (t, args, type) r = copy_decl (t); DECL_USE_TEMPLATE (r) = 0; TREE_TYPE (r) = type; + /* Clear out the mangled name and RTL for the instantiation. */ + SET_DECL_ASSEMBLER_NAME (r, NULL_TREE); + SET_DECL_RTL (r, NULL_RTX); DECL_CONTEXT (r) = ctx; DECL_VIRTUAL_CONTEXT (r) @@ -5839,9 +5816,9 @@ tsubst_decl (t, args, type) TREE_CHAIN (DECL_CLONED_FUNCTION (r)) = r; } - /* Set up the DECL_TEMPLATE_INFO for R and compute its mangled - name. There's no need to do this in the special friend - case mentioned above where GEN_TMPL is NULL. */ + /* Set up the DECL_TEMPLATE_INFO for R. There's no need to do + this in the special friend case mentioned above where + GEN_TMPL is NULL. */ if (gen_tmpl) { DECL_TEMPLATE_INFO (r) @@ -5849,37 +5826,6 @@ tsubst_decl (t, args, type) SET_DECL_IMPLICIT_INSTANTIATION (r); register_specialization (r, gen_tmpl, argvec); - /* Set the mangled name for R. */ - if (DECL_DESTRUCTOR_P (t)) - set_mangled_name_for_decl (r); - else - { - /* Instantiations of template functions must be mangled - specially, in order to conform to 14.5.5.1 - [temp.over.link]. */ - tree tmpl = DECL_TI_TEMPLATE (t); - - /* TMPL will be NULL if this is a specialization of a - member function of a template class. */ - if (tmpl == NULL_TREE - || (member && !is_member_template (tmpl) - && !DECL_TEMPLATE_INFO (tmpl))) - set_mangled_name_for_decl (r); - else - set_mangled_name_for_template_decl (r); - } - - SET_DECL_RTL (r, NULL_RTX); - - /* Like grokfndecl. If we don't do this, pushdecl will - mess up our TREE_CHAIN because it doesn't find a - previous decl. Sigh. */ - if (member - && ! uses_template_parms (r) - && (IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (r)) - == NULL_TREE)) - SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (r), r); - /* We're not supposed to instantiate default arguments until they are called, for a template. But, for a declaration like: @@ -6032,6 +5978,9 @@ tsubst_decl (t, args, type) TREE_TYPE (r) = type; c_apply_type_quals_to_decl (CP_TYPE_QUALS (type), r); DECL_CONTEXT (r) = ctx; + /* Clear out the mangled name and RTL for the instantiation. */ + SET_DECL_ASSEMBLER_NAME (r, NULL_TREE); + SET_DECL_RTL (r, NULL_RTX); /* Don't try to expand the initializer until someone tries to use this variable; otherwise we run into circular dependencies. */ @@ -9762,7 +9711,7 @@ regenerate_decl_from_template (decl, tmpl) functions, this is not so. See tsubst_friend_function for details. */ DECL_TI_TEMPLATE (new_decl) = DECL_TI_TEMPLATE (decl); - DECL_ASSEMBLER_NAME (new_decl) = DECL_ASSEMBLER_NAME (decl); + COPY_DECL_ASSEMBLER_NAME (decl, new_decl); COPY_DECL_RTL (decl, new_decl); DECL_USE_TEMPLATE (new_decl) = DECL_USE_TEMPLATE (decl); @@ -10292,21 +10241,6 @@ get_mostly_instantiated_function_type (decl, contextp, tparmsp) return fn_type; } -/* Set the DECL_ASSEMBLER_NAME for DECL, which is a FUNCTION_DECL that - is either an instantiation or specialization of a template - function. */ - -static void -set_mangled_name_for_template_decl (decl) - tree decl; -{ - my_friendly_assert (TREE_CODE (decl) == FUNCTION_DECL, 0); - my_friendly_assert (DECL_TEMPLATE_INFO (decl) != NULL_TREE, 0); - - /* Under the new ABI, we don't need special machinery. */ - set_mangled_name_for_decl (decl); -} - /* Return truthvalue if we're processing a template different from the last one involved in diagnostics. */ int |