]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[C++ PATCH] Kill IDENTIFIER_GLOBAL_VALUE
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 5 Oct 2017 12:10:55 +0000 (12:10 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 5 Oct 2017 12:10:55 +0000 (12:10 +0000)
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00239.html
Kill IDENTIFIER_GLOBAL_VALUE, SET_IDENTIFIER_GLOBAL_VALUE
* cp-tree.h (IDENTIFIER_GLOBAL_VALUE,
SET_IDENTIFIER_GLOBAL_VALUE): Delete.
* name-lookup.h (set_global_binding): Remove NAME parm.
(get_global_binding): New inline fn.
* name-lookup.c (set_global_binding): Remove NAME parm. Adjust.
(identifier_global_value): Move to ...
* cp-objcp-common.c (identifier_global_value): ... here.
* class.c (build_ctor_vtbl_group, build_vtbl_initializer): Adjust.
* decl.c (record_builtin_type, expand_static_init,
grokdeclarator): Adjust.
* decl2.c (get_guard, get_local_tls_init_fn, get_tls_init_fn,
get_tls_wrapper_fn, maybe_warn_sized_delete): Adjust.
* except.c (declare_library_fn, build_throw): Adjust.
* init.c (throw_bad_array_length): Adjust.
* rtti.c (throw_bad_cast, throw_bad_typeid, get_tinfo_decl): Adjust.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253444 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-objcp-common.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/except.c
gcc/cp/init.c
gcc/cp/name-lookup.c
gcc/cp/name-lookup.h
gcc/cp/rtti.c

index fcef8efe2abdb7ac945a67fb3bf4672eb02415b2..75778465200beb985753338a3e313f751076aac6 100644 (file)
@@ -1,5 +1,22 @@
 2017-10-05  Nathan Sidwell  <nathan@acm.org>
 
+       Kill IDENTIFIER_GLOBAL_VALUE, SET_IDENTIFIER_GLOBAL_VALUE
+       * cp-tree.h (IDENTIFIER_GLOBAL_VALUE,
+       SET_IDENTIFIER_GLOBAL_VALUE): Delete.
+       * name-lookup.h (set_global_binding): Remove NAME parm.
+       (get_global_binding): New inline fn.
+       * name-lookup.c (set_global_binding): Remove NAME parm. Adjust.
+       (identifier_global_value): Move to ...
+       * cp-objcp-common.c (identifier_global_value): ... here.
+       * class.c (build_ctor_vtbl_group, build_vtbl_initializer): Adjust.
+       * decl.c (record_builtin_type, expand_static_init,
+       grokdeclarator): Adjust.
+       * decl2.c (get_guard, get_local_tls_init_fn, get_tls_init_fn,
+       get_tls_wrapper_fn, maybe_warn_sized_delete): Adjust.
+       * except.c (declare_library_fn, build_throw): Adjust.
+       * init.c (throw_bad_array_length): Adjust.
+       * rtti.c (throw_bad_cast, throw_bad_typeid, get_tinfo_decl): Adjust.
+
        * decl2.c (record_mangling): Fix spello and formatting from
        previous patch.
 
index 0c4a7b3db0419cc393613a74269706acf03355c2..a90b85f2a5c731c7ade73223edd4f9269cc1d06e 100644 (file)
@@ -8912,7 +8912,7 @@ build_ctor_vtbl_group (tree binfo, tree t)
 
   /* See if we've already created this construction vtable group.  */
   id = mangle_ctor_vtbl_for_type (t, binfo);
-  if (IDENTIFIER_GLOBAL_VALUE (id))
+  if (get_global_binding (id))
     return;
 
   gcc_assert (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t));
@@ -9294,7 +9294,7 @@ build_vtbl_initializer (tree binfo,
              if (!dvirt_fn)
                {
                  tree name = get_identifier ("__cxa_deleted_virtual");
-                 dvirt_fn = IDENTIFIER_GLOBAL_VALUE (name);
+                 dvirt_fn = get_global_binding (name);
                  if (!dvirt_fn)
                    dvirt_fn = push_library_fn
                      (name,
index 267fcca7319e6c253574538552f21d203752eb53..f251b05775b2dc06864e29b2f906b65bf51cf009 100644 (file)
@@ -400,6 +400,15 @@ cp_pushdecl (tree decl)
   return pushdecl (decl);
 }
 
+/* Get the global value binding of NAME.  Called directly from
+   c-common.c, not via a hook. */
+
+tree
+identifier_global_value (tree name)
+{
+  return get_global_binding (name);
+}
+
 /* Register c++-specific dumps.  */
 
 void
index 82ebc2831c586e3952b0c03f7132066bf34bc32e..5f9874ba10b904402ed5ff77c322c43dd3530fd9 100644 (file)
@@ -613,11 +613,6 @@ struct GTY(()) ptrmem_cst {
 };
 typedef struct ptrmem_cst * ptrmem_cst_t;
 
-#define IDENTIFIER_GLOBAL_VALUE(NODE) \
-  get_namespace_binding (NULL_TREE, (NODE))
-#define SET_IDENTIFIER_GLOBAL_VALUE(NODE, VAL) \
-  set_global_binding ((NODE), (VAL))
-
 #define CLEANUP_P(NODE)                TREE_LANG_FLAG_0 (TRY_BLOCK_CHECK (NODE))
 
 #define BIND_EXPR_TRY_BLOCK(NODE) \
index 99f0af237566e605732b85e3eb3d0b32675698f3..2b4ed0131e0d89b744e14bc2afc5997d92cf0578 100644 (file)
@@ -3897,7 +3897,7 @@ make_unbound_class_template (tree context, tree name, tree parm_list,
    RID_POINTERS.  NAME is the name used when looking up the builtin
    type.  TYPE is the _TYPE node for the builtin type.
 
-   The calls to SET_IDENTIFIER_GLOBAL_VALUE below should be
+   The calls to set_global_binding below should be
    eliminated.  Built-in types should not be looked up name; their
    names are keywords that the parser can recognize.  However, there
    is code in c-common.c that uses identifier_global_value to look up
@@ -3915,7 +3915,7 @@ record_builtin_type (enum rid rid_index,
       tree tname = get_identifier (name);
       tree tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, tname, type);
       DECL_ARTIFICIAL (tdecl) = 1;
-      SET_IDENTIFIER_GLOBAL_VALUE (tname, tdecl);
+      set_global_binding (tdecl);
       decl = tdecl;
     }
 
@@ -3925,7 +3925,7 @@ record_builtin_type (enum rid rid_index,
        {
          tree rdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, rname, type);
          DECL_ARTIFICIAL (rdecl) = 1;
-         SET_IDENTIFIER_GLOBAL_VALUE (rname, rdecl);
+         set_global_binding (rdecl);
          if (!decl)
            decl = rdecl;
        }
@@ -4509,7 +4509,7 @@ build_cp_library_fn_ptr (const char* name, tree type, int ecf_flags)
 }
 
 /* Like build_library_fn, but also pushes the function so that we will
-   be able to find it via IDENTIFIER_GLOBAL_VALUE.  Also, the function
+   be able to find it via get_global_binding.  Also, the function
    may throw exceptions listed in RAISES.  */
 
 tree
@@ -8055,9 +8055,9 @@ expand_static_init (tree decl, tree init)
          acquire_name = get_identifier ("__cxa_guard_acquire");
          release_name = get_identifier ("__cxa_guard_release");
          abort_name = get_identifier ("__cxa_guard_abort");
-         acquire_fn = identifier_global_value (acquire_name);
-         release_fn = identifier_global_value (release_name);
-         abort_fn = identifier_global_value (abort_name);
+         acquire_fn = get_global_binding (acquire_name);
+         release_fn = get_global_binding (release_name);
+         abort_fn = get_global_binding (abort_name);
          if (!acquire_fn)
            acquire_fn = push_library_fn
              (acquire_name, build_function_type_list (integer_type_node,
@@ -10126,7 +10126,7 @@ grokdeclarator (const cp_declarator *declarator,
                    gcc_assert (flags == NO_SPECIAL);
                    flags = TYPENAME_FLAG;
                    sfk = sfk_conversion;
-                   tree glob = IDENTIFIER_GLOBAL_VALUE (dname);
+                   tree glob = get_global_binding (dname);
                    if (glob && TREE_CODE (glob) == TYPE_DECL)
                      name = identifier_to_locale (IDENTIFIER_POINTER (dname));
                    else
index 3aa2db5bc541d3c52dab92f371980cf399914460..ee4c80077eda250d0b57d56c03b3e8f8d21f31fb 100644 (file)
@@ -2985,7 +2985,7 @@ get_guard (tree decl)
   tree guard;
 
   sname = mangle_guard_variable (decl);
-  guard = IDENTIFIER_GLOBAL_VALUE (sname);
+  guard = get_global_binding (sname);
   if (! guard)
     {
       tree guard_type;
@@ -3153,7 +3153,7 @@ static tree
 get_local_tls_init_fn (void)
 {
   tree sname = get_identifier ("__tls_init");
-  tree fn = IDENTIFIER_GLOBAL_VALUE (sname);
+  tree fn = get_global_binding (sname);
   if (!fn)
     {
       fn = build_lang_decl (FUNCTION_DECL, sname,
@@ -3163,7 +3163,7 @@ get_local_tls_init_fn (void)
       TREE_PUBLIC (fn) = false;
       DECL_ARTIFICIAL (fn) = true;
       mark_used (fn);
-      SET_IDENTIFIER_GLOBAL_VALUE (sname, fn);
+      set_global_binding (fn);
     }
   return fn;
 }
@@ -3191,7 +3191,7 @@ get_tls_init_fn (tree var)
     return get_local_tls_init_fn ();
 
   tree sname = mangle_tls_init_fn (var);
-  tree fn = IDENTIFIER_GLOBAL_VALUE (sname);
+  tree fn = get_global_binding (sname);
   if (!fn)
     {
       fn = build_lang_decl (FUNCTION_DECL, sname,
@@ -3225,7 +3225,7 @@ get_tls_init_fn (tree var)
 
       DECL_BEFRIENDING_CLASSES (fn) = var;
 
-      SET_IDENTIFIER_GLOBAL_VALUE (sname, fn);
+      set_global_binding (fn);
     }
   return fn;
 }
@@ -3243,7 +3243,7 @@ get_tls_wrapper_fn (tree var)
     return NULL_TREE;
 
   tree sname = mangle_tls_wrapper_fn (var);
-  tree fn = IDENTIFIER_GLOBAL_VALUE (sname);
+  tree fn = get_global_binding (sname);
   if (!fn)
     {
       /* A named rvalue reference is an lvalue, so the wrapper should
@@ -3282,7 +3282,7 @@ get_tls_wrapper_fn (tree var)
 
       DECL_BEFRIENDING_CLASSES (fn) = var;
 
-      SET_IDENTIFIER_GLOBAL_VALUE (sname, fn);
+      set_global_binding (fn);
     }
   return fn;
 }
@@ -4427,7 +4427,7 @@ maybe_warn_sized_delete (enum tree_code code)
   tree sized = NULL_TREE;
   tree unsized = NULL_TREE;
 
-  for (ovl_iterator iter (IDENTIFIER_GLOBAL_VALUE (cp_operator_id (code)));
+  for (ovl_iterator iter (get_global_binding (cp_operator_id (code)));
        iter; ++iter)
     {
       tree fn = *iter;
index 2ee7e97ea2315f0a6ea8bcb0bf31f180021fc472..ecc8941984b317b4140d21f94935ae7ffd8f1d33 100644 (file)
@@ -147,7 +147,7 @@ declare_library_fn (const char *name, tree rtype, tree ptype,
                    int ecf, int tm_ecf)
 {
   tree ident = get_identifier (name);
-  tree res = IDENTIFIER_GLOBAL_VALUE (ident);
+  tree res = get_global_binding (ident);
   if (!res)
     {
       tree type = build_function_type_list (rtype, ptype, NULL_TREE);
@@ -158,7 +158,7 @@ declare_library_fn (const char *name, tree rtype, tree ptype,
          char *tm_name = concat ("_ITM_", name + 2, NULL_TREE);
          tree tm_ident = get_identifier (tm_name);
          free (tm_name);
-         tree tm_fn = IDENTIFIER_GLOBAL_VALUE (tm_ident);
+         tree tm_fn = get_global_binding (tm_ident);
          if (!tm_fn)
            tm_fn = push_library_fn (tm_ident, type, except, ecf | tm_ecf);
          record_tm_replacement (res, tm_fn);
@@ -609,7 +609,7 @@ build_throw (tree exp)
       if (!throw_fn)
        {
          tree name = get_identifier ("__cxa_throw");
-         throw_fn = IDENTIFIER_GLOBAL_VALUE (name);
+         throw_fn = get_global_binding (name);
          if (!throw_fn)
            {
              /* Declare void __cxa_throw (void*, void*, void (*)(void*)).  */
@@ -622,7 +622,7 @@ build_throw (tree exp)
              if (flag_tm)
                {
                  tree itm_name = get_identifier ("_ITM_cxa_throw");
-                 tree itm_fn = IDENTIFIER_GLOBAL_VALUE (itm_name);
+                 tree itm_fn = get_global_binding (itm_name);
                  if (!itm_fn)
                    itm_fn = push_throw_library_fn (itm_name, tmp);
                  apply_tm_attr (itm_fn, get_identifier ("transaction_pure"));
@@ -764,7 +764,7 @@ build_throw (tree exp)
       if (!rethrow_fn)
        {
          tree name = get_identifier ("__cxa_rethrow");
-         rethrow_fn = IDENTIFIER_GLOBAL_VALUE (name);
+         rethrow_fn = get_global_binding (name);
          if (!rethrow_fn)
            /* Declare void __cxa_rethrow (void).  */
            rethrow_fn = push_throw_library_fn
index 4bc0755cdcbd693da2e1dff6088c7fe550786dd1..ad30f247cf6995360c1e251bb88a132c3a6b4bcf 100644 (file)
@@ -2446,7 +2446,7 @@ throw_bad_array_new_length (void)
     {
       tree name = get_identifier ("__cxa_throw_bad_array_new_length");
 
-      fn = IDENTIFIER_GLOBAL_VALUE (name);
+      fn = get_global_binding (name);
       if (!fn)
        fn = push_throw_library_fn
          (name, build_function_type_list (sizetype, NULL_TREE));
index c72a7f4eb5f64fc83f39deff362c7be2f77cdf67..a20c603243aef4a538502512966430b253e95b9e 100644 (file)
@@ -3774,16 +3774,6 @@ identifier_type_value (tree id)
   return ret;
 }
 
-
-/* Return the IDENTIFIER_GLOBAL_VALUE of T, for use in common code, since
-   the definition of IDENTIFIER_GLOBAL_VALUE is different for C and C++.  */
-
-tree
-identifier_global_value        (tree t)
-{
-  return IDENTIFIER_GLOBAL_VALUE (t);
-}
-
 /* Push a definition of struct, union or enum tag named ID.  into
    binding_level B.  DECL is a TYPE_DECL for the type.  We assume that
    the tag ID is not already defined.  */
@@ -4839,32 +4829,32 @@ get_namespace_binding (tree ns, tree name)
   return ret;
 }
 
-/* Set value binding of NAME in the global namespace to VAL.  Does not
-   add it to the list of things in the namespace.  */
+/* Push internal DECL into the global namespace.  Does not do the
+   full overload fn handling and does not add it to the list of things
+   in the namespace.  */
 
 void
-set_global_binding (tree name, tree val)
+set_global_binding (tree decl)
 {
   bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
 
-  gcc_checking_assert (name == DECL_NAME (val));
-  tree *slot = find_namespace_slot (global_namespace, name, true);
+  tree *slot = find_namespace_slot (global_namespace, DECL_NAME (decl), true);
   tree old = MAYBE_STAT_DECL (*slot);
 
   if (!old)
-    *slot = val;
-  else if (old == val)
+    *slot = decl;
+  else if (old == decl)
     ;
   else if (!STAT_HACK_P (*slot)
-          && TREE_CODE (val) == TYPE_DECL && DECL_ARTIFICIAL (val))
-    *slot = stat_hack (old, val);
+          && TREE_CODE (decl) == TYPE_DECL && DECL_ARTIFICIAL (decl))
+    *slot = stat_hack (old, decl);
   else if (!STAT_HACK_P (*slot)
           && TREE_CODE (old) == TYPE_DECL && DECL_ARTIFICIAL (old))
-    *slot = stat_hack (val, old);
+    *slot = stat_hack (decl, old);
   else
     /* The user's placed something in the implementor's
        namespace.  */
-    diagnose_name_conflict (val, old);
+    diagnose_name_conflict (decl, old);
 
   timevar_cond_stop (TV_NAME_LOOKUP, subtime);
 }
index 2e5539fd80e0368e97f6a20e2236b856dd739565..bf0bf85cd53b412899589dd436eab646bd891e3c 100644 (file)
@@ -178,9 +178,6 @@ struct GTY(()) cp_label_binding {
    CURRENT_BINDING_LEVEL.  You should use lookup_name_current_level
    instead.  */
 
-/* Note that the information in the `names' component of the global contour
-   is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers.  */
-
 struct GTY(()) cp_binding_level {
   /* A chain of _DECL nodes for all variables, constants, functions,
       and typedef types.  These are in the reverse of the order
@@ -303,7 +300,11 @@ extern tree lookup_name_prefer_type (tree, int);
 extern tree lookup_name_real (tree, int, int, bool, int, int);
 extern tree lookup_type_scope (tree, tag_scope);
 extern tree get_namespace_binding (tree ns, tree id);
-extern void set_global_binding (tree id, tree val);
+extern void set_global_binding (tree decl);
+inline tree get_global_binding (tree id)
+{
+  return get_namespace_binding (NULL_TREE, id);
+}
 extern tree lookup_qualified_name (tree, tree, int, bool, /*hidden*/bool = false);
 extern tree lookup_name_nonclass (tree);
 extern bool is_local_extern (tree);
index a660cdd9413b47e9932545fd68a7f580e7b4b4d5..5b2326cbbb63cda1c126e052ca4afd0436f7a649 100644 (file)
@@ -52,7 +52,7 @@ along with GCC; see the file COPYING3.  If not see
    type_info objects for static initialization.
 
    The type information VAR_DECL of a type is held on the
-   IDENTIFIER_GLOBAL_VALUE of the type's mangled name. That VAR_DECL
+   get_global_binding of the type's mangled name. That VAR_DECL
    will be the internal type.  It will usually have the correct
    internal type reflecting the kind of type it represents (pointer,
    array, function, class, inherited class, etc).  When the type it
@@ -226,7 +226,7 @@ throw_bad_cast (void)
   if (!fn)
     {
       tree name = get_identifier ("__cxa_bad_cast");
-      fn = IDENTIFIER_GLOBAL_VALUE (name);
+      fn = get_global_binding (name);
       if (!fn)
        fn = push_throw_library_fn
          (name, build_function_type_list (ptr_type_node, NULL_TREE));
@@ -245,7 +245,7 @@ throw_bad_typeid (void)
   if (!fn)
     {
       tree name = get_identifier ("__cxa_bad_typeid");
-      fn = IDENTIFIER_GLOBAL_VALUE (name);
+      fn = get_global_binding (name);
       if (!fn)
        {
          tree t = build_reference_type (const_type_info_type_node);
@@ -446,7 +446,7 @@ get_tinfo_decl (tree type)
 
   name = mangle_typeinfo_for_type (type);
 
-  d = IDENTIFIER_GLOBAL_VALUE (name);
+  d = get_global_binding (name);
   if (!d)
     {
       int ix = get_pseudo_ti_index (type);