aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorTrevor Saunders <tsaunders@mozilla.com>2014-10-12 22:22:53 +0000
committerTrevor Saunders <tbsaunde@gcc.gnu.org>2014-10-12 22:22:53 +0000
commit2a22f99cb12d82712dd93cfef808b1cef543601b (patch)
treec828063f153ceb609ce5c7d44ea9f00391b32950 /gcc/cp/semantics.c
parent7b262a51ea2310bdb6cc901de00f04b0e7be0a4e (diff)
downloadgcc-2a22f99cb12d82712dd93cfef808b1cef543601b.zip
gcc-2a22f99cb12d82712dd93cfef808b1cef543601b.tar.gz
gcc-2a22f99cb12d82712dd93cfef808b1cef543601b.tar.bz2
move many gc hashtab to hash_table
gcc/ * asan.c, cfgloop.c, cfgloop.h, cgraph.c, cgraph.h, config/darwin.c, config/m32c/m32c.c, config/mep/mep.c, config/mips/mips.c, config/rs6000/rs6000.c, dwarf2out.c, function.c, function.h, gimple-ssa.h, libfuncs.h, optabs.c, output.h, rtl.h, sese.c, symtab.c, tree-cfg.c, tree-dfa.c, tree-ssa.c, varasm.c: Use hash-table instead of hashtab. * doc/gty.texi (for_user): Document new option. * gengtype.c (create_user_defined_type): Don't try to get a struct for char. (walk_type): Don't error out on for_user option. (write_func_for_structure): Emit user marking routines if requested by for_user option. (write_local_func_for_structure): Likewise. (main): Mark types with for_user option as used. * ggc.h (gt_pch_nx): Add overload for unsigned int. * hash-map.h (hash_map::hash_entry::pch_nx_helper): AddOverloads. * hash-table.h (ggc_hasher): New struct. (hash_table::create_ggc): New function. (gt_pch_nx): New overload for hash_table. java/ * class.c, decl.c, except.c, expr.c, java-tree.h, lang.c: Use hash_table instead of hashtab. objc/ * objc-act.c: use hash_table instead of hashtab. cp/ * cp-gimplify.c, cp-tree.h, decl.c, mangle.c, name-lookup.c, pt.c, semantics.c, tree.c, typeck2.c: Use hash_table instead of hashtab. fortran/ * trans-decl.c, trans.c, trans.h: Use hash_table instead of hashtab. c-family/ * c-common.c: Use hash_table instead of hashtab. From-SVN: r216127
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 08658a7..85d5383 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7579,35 +7579,38 @@ ensure_literal_type_for_constexpr_object (tree decl)
/* Representation of entries in the constexpr function definition table. */
-typedef struct GTY(()) constexpr_fundef {
+struct GTY((for_user)) constexpr_fundef {
tree decl;
tree body;
-} constexpr_fundef;
+};
+
+struct constexpr_fundef_hasher : ggc_hasher<constexpr_fundef *>
+{
+ static hashval_t hash (constexpr_fundef *);
+ static bool equal (constexpr_fundef *, constexpr_fundef *);
+};
/* This table holds all constexpr function definitions seen in
the current translation unit. */
-static GTY ((param_is (constexpr_fundef))) htab_t constexpr_fundef_table;
+static GTY (()) hash_table<constexpr_fundef_hasher> *constexpr_fundef_table;
/* Utility function used for managing the constexpr function table.
Return true if the entries pointed to by P and Q are for the
same constexpr function. */
-static inline int
-constexpr_fundef_equal (const void *p, const void *q)
+inline bool
+constexpr_fundef_hasher::equal (constexpr_fundef *lhs, constexpr_fundef *rhs)
{
- const constexpr_fundef *lhs = (const constexpr_fundef *) p;
- const constexpr_fundef *rhs = (const constexpr_fundef *) q;
return lhs->decl == rhs->decl;
}
/* Utility function used for managing the constexpr function table.
Return a hash value for the entry pointed to by Q. */
-static inline hashval_t
-constexpr_fundef_hash (const void *p)
+inline hashval_t
+constexpr_fundef_hasher::hash (constexpr_fundef *fundef)
{
- const constexpr_fundef *fundef = (const constexpr_fundef *) p;
return DECL_UID (fundef->decl);
}
@@ -7621,7 +7624,7 @@ retrieve_constexpr_fundef (tree fun)
return NULL;
fundef.decl = fun;
- return (constexpr_fundef *) htab_find (constexpr_fundef_table, &fundef);
+ return constexpr_fundef_table->find (&fundef);
}
/* Check whether the parameter and return types of FUN are valid for a
@@ -8236,14 +8239,12 @@ register_constexpr_fundef (tree fun, tree body)
/* Create the constexpr function table if necessary. */
if (constexpr_fundef_table == NULL)
- constexpr_fundef_table = htab_create_ggc (101,
- constexpr_fundef_hash,
- constexpr_fundef_equal,
- ggc_free);
+ constexpr_fundef_table
+ = hash_table<constexpr_fundef_hasher>::create_ggc (101);
+
entry.decl = fun;
entry.body = body;
- slot = (constexpr_fundef **)
- htab_find_slot (constexpr_fundef_table, &entry, INSERT);
+ slot = constexpr_fundef_table->find_slot (&entry, INSERT);
gcc_assert (*slot == NULL);
*slot = ggc_alloc<constexpr_fundef> ();
@@ -8296,7 +8297,7 @@ explain_invalid_constexpr_fn (tree fun)
along with the bindings of parameters to their arguments, for
the purpose of compile time evaluation. */
-typedef struct GTY(()) constexpr_call {
+struct GTY((for_user)) constexpr_call {
/* Description of the constexpr function definition. */
constexpr_fundef *fundef;
/* Parameter bindings environment. A TREE_LIST where each TREE_PURPOSE
@@ -8314,39 +8315,42 @@ typedef struct GTY(()) constexpr_call {
/* The hash of this call; we remember it here to avoid having to
recalculate it when expanding the hash table. */
hashval_t hash;
-} constexpr_call;
+};
+
+struct constexpr_call_hasher : ggc_hasher<constexpr_call *>
+{
+ static hashval_t hash (constexpr_call *);
+ static bool equal (constexpr_call *, constexpr_call *);
+ };
/* A table of all constexpr calls that have been evaluated by the
compiler in this translation unit. */
-static GTY ((param_is (constexpr_call))) htab_t constexpr_call_table;
+static GTY (()) hash_table<constexpr_call_hasher> *constexpr_call_table;
static tree cxx_eval_constant_expression (const constexpr_call *, tree,
bool, bool, bool *, bool *);
/* Compute a hash value for a constexpr call representation. */
-static hashval_t
-constexpr_call_hash (const void *p)
+inline hashval_t
+constexpr_call_hasher::hash (constexpr_call *info)
{
- const constexpr_call *info = (const constexpr_call *) p;
return info->hash;
}
-/* Return 1 if the objects pointed to by P and Q represent calls
+/* Return true if the objects pointed to by P and Q represent calls
to the same constexpr function with the same arguments.
- Otherwise, return 0. */
+ Otherwise, return false. */
-static int
-constexpr_call_equal (const void *p, const void *q)
+bool
+constexpr_call_hasher::equal (constexpr_call *lhs, constexpr_call *rhs)
{
- const constexpr_call *lhs = (const constexpr_call *) p;
- const constexpr_call *rhs = (const constexpr_call *) q;
tree lhs_bindings;
tree rhs_bindings;
if (lhs == rhs)
return 1;
- if (!constexpr_fundef_equal (lhs->fundef, rhs->fundef))
+ if (!constexpr_fundef_hasher::equal (lhs->fundef, rhs->fundef))
return 0;
lhs_bindings = lhs->bindings;
rhs_bindings = rhs->bindings;
@@ -8369,10 +8373,7 @@ static void
maybe_initialize_constexpr_call_table (void)
{
if (constexpr_call_table == NULL)
- constexpr_call_table = htab_create_ggc (101,
- constexpr_call_hash,
- constexpr_call_equal,
- ggc_free);
+ constexpr_call_table = hash_table<constexpr_call_hasher>::create_ggc (101);
}
/* Return true if T designates the implied `this' parameter. */
@@ -8681,12 +8682,11 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t,
new_call.hash
= iterative_hash_template_arg (new_call.bindings,
- constexpr_fundef_hash (new_call.fundef));
+ constexpr_fundef_hasher::hash (new_call.fundef));
/* If we have seen this call before, we are done. */
maybe_initialize_constexpr_call_table ();
- slot = (constexpr_call **)
- htab_find_slot (constexpr_call_table, &new_call, INSERT);
+ slot = constexpr_call_table->find_slot (&new_call, INSERT);
entry = *slot;
if (entry == NULL)
{