public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] Change cxx_int_tree_map to cxx_decl_tree_map
@ 2020-09-14 12:54 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-09-14 12:54 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:b63aa6567ee5e266f0b70156c8910388397844fd

commit b63aa6567ee5e266f0b70156c8910388397844fd
Author: Nathan Sidwell <nathan@acm.org>
Date:   Tue Sep 8 10:37:56 2020 -0700

    Change cxx_int_tree_map to cxx_decl_tree_map
    
            gcc/cp/
            * cp-tree.h (struct cxx_int_tree_map): Rename to ...
            (struct cxx_decl_tree_map): ... here.
            * cp-gimplify.c (cxx_int_tree_map_hasher): Rename to ...
            (cxx_decl_tree_map_hasher): ... here.  Update member fns
            (cp_genericize_r): Adjust extern_decl_map lookup.
            * name-lookup.c (set_local_extern_decl_linkage): Adjust
            extern_decl_map insertion.

Diff:
---
 ChangeLog.modules    | 12 ++++++++++++
 gcc/cp/cp-gimplify.c | 19 +++++++++----------
 gcc/cp/cp-tree.h     | 18 +++++++++++-------
 gcc/cp/name-lookup.c | 13 ++++++-------
 4 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/ChangeLog.modules b/ChangeLog.modules
index aeea11e7e63..5e87761e803 100644
--- a/ChangeLog.modules
+++ b/ChangeLog.modules
@@ -1,3 +1,15 @@
+2020-09-08  Nathan Sidwell  <nathan@acm.org>
+
+	Change cxx_int_tree_map to cxx_decl_tree_map.
+	gcc/cp/
+	* cp-tree.h (struct cxx_int_tree_map): Rename to ...
+	(struct cxx_decl_tree_map): ... here.
+	* cp-gimplify.c (cxx_int_tree_map_hasher): Rename to ...
+	(cxx_decl_tree_map_hasher): ... here.  Update member fns
+	(cp_genericize_r): Adjust extern_decl_map lookup.
+	* name-lookup.c (set_local_extern_decl_linkage): Adjust
+	extern_decl_map insertion.
+
 2020-09-12  Nathan Sidwell  <nathan@acm.org>
 
 	FLAG DAY! Mapper reponse format change in LibCody
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index f8695835684..ee8b8ae274b 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -962,20 +962,20 @@ is_invisiref_parm (const_tree t)
 	  && DECL_BY_REFERENCE (t));
 }
 
-/* Return true if the uid in both int tree maps are equal.  */
+/* Return true if the decls in both decl tree maps are equal.  */
 
 bool
-cxx_int_tree_map_hasher::equal (cxx_int_tree_map *a, cxx_int_tree_map *b)
+cxx_decl_tree_map_hasher::equal (cxx_decl_tree_map *a, cxx_decl_tree_map *b)
 {
-  return (a->uid == b->uid);
+  return (a->decl == b->decl);
 }
 
-/* Hash a UID in a cxx_int_tree_map.  */
+/* Hash a UID in a cxx_decl_tree_map.  */
 
 unsigned int
-cxx_int_tree_map_hasher::hash (cxx_int_tree_map *item)
+cxx_decl_tree_map_hasher::hash (cxx_decl_tree_map *item)
 {
-  return item->uid;
+  return DECL_UID (item->decl);
 }
 
 /* A stable comparison routine for use with splay trees and DECLs.  */
@@ -1266,10 +1266,9 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
       && VAR_OR_FUNCTION_DECL_P (stmt)
       && DECL_EXTERNAL (stmt))
     {
-      struct cxx_int_tree_map *h, in;
-      in.uid = DECL_UID (stmt);
-      h = cp_function_chain->extern_decl_map->find_with_hash (&in, in.uid);
-      if (h)
+      cxx_decl_tree_map in;
+      in.decl = stmt;
+      if (auto *h = cp_function_chain->extern_decl_map->find (&in))
 	{
 	  *stmt_p = h->to;
 	  TREE_USED (h->to) |= TREE_USED (stmt);
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 3b5f038fa5c..ce4045d5a89 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2005,17 +2005,18 @@ public:
 
 #define cp_noexcept_operand scope_chain->noexcept_operand
 
-/* A list of private types mentioned, for deferred access checking.  */
+/* Map a _DECL to a tree.  Use DECL_UID for hash.  Both trees must be
+   reachable for GC via some other path.  */
 
-struct GTY((for_user)) cxx_int_tree_map {
-  unsigned int uid;
+struct GTY((for_user)) cxx_decl_tree_map {
+  tree decl;
   tree to;
 };
 
-struct cxx_int_tree_map_hasher : ggc_ptr_hash<cxx_int_tree_map>
+struct cxx_decl_tree_map_hasher : ggc_ptr_hash<cxx_decl_tree_map>
 {
-  static hashval_t hash (cxx_int_tree_map *);
-  static bool equal (cxx_int_tree_map *, cxx_int_tree_map *);
+  static hashval_t hash (cxx_decl_tree_map *);
+  static bool equal (cxx_decl_tree_map *, cxx_decl_tree_map *);
 };
 
 struct named_label_entry; /* Defined in decl.c.  */
@@ -2070,7 +2071,10 @@ struct GTY(()) language_function {
   /* Tracking possibly infinite loops.  This is a vec<tree> only because
      vec<bool> doesn't work with gtype.  */
   vec<tree, va_gc> *infinite_loops;
-  hash_table<cxx_int_tree_map_hasher> *extern_decl_map;
+
+  /* Map of block-scope extern decls to the namespace-scope decl they
+     match.  Usually empty.  */
+  hash_table<cxx_decl_tree_map_hasher> *extern_decl_map;
 };
 
 /* The current C++-specific per-function global variables.  */
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index b4b531881b8..b6625c09a3f 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3522,21 +3522,20 @@ set_local_extern_decl_linkage (tree decl, bool shadowed)
 	       args are not shared.  Add the decl into a hash table to
 	       make sure only the previous decl in this case is seen
 	       by the middle end.  */
-	    struct cxx_int_tree_map *h;
-
 	    /* We inherit the outer decl's linkage.  But we're a
 	       different decl.  */
 	    TREE_PUBLIC (decl) = TREE_PUBLIC (*iter);
 
 	    if (cp_function_chain->extern_decl_map == NULL)
 	      cp_function_chain->extern_decl_map
-		= hash_table<cxx_int_tree_map_hasher>::create_ggc (20);
+		= hash_table<cxx_decl_tree_map_hasher>::create_ggc (20);
 
-	    h = ggc_alloc<cxx_int_tree_map> ();
-	    h->uid = DECL_UID (decl);
+	    auto *h = ggc_alloc<cxx_decl_tree_map> ();
+	    h->decl = decl;
 	    h->to = *iter;
-	    cxx_int_tree_map **loc = cp_function_chain->extern_decl_map
-	      ->find_slot (h, INSERT);
+	    auto **loc
+	      = cp_function_chain->extern_decl_map->find_slot (h, INSERT);
+	    gcc_checking_assert (!*loc);
 	    *loc = h;
 	    break;
 	  }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-14 12:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 12:54 [gcc/devel/c++-modules] Change cxx_int_tree_map to cxx_decl_tree_map Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).