[gcc/devel/c++-modules] Adjust template spec accessor
Nathan Sidwell
nathan@gcc.gnu.org
Fri Nov 20 15:23:27 GMT 2020
https://gcc.gnu.org/g:a089fe1fbbe6b8a5ce69466822529d21d3012440
commit a089fe1fbbe6b8a5ce69466822529d21d3012440
Author: Nathan Sidwell <nathan@acm.org>
Date: Fri Nov 20 04:46:04 2020 -0800
Adjust template spec accessor
gcc/cp/
* cp-tree.h (match_mergeable_specialization): Take a spec_entry.
* pt.c (match_mergeable_specialization): Likewise.
* module.cc (trees_in::decl_value): Adjust.
(trees_{in,out}::key_mergeable): Adjust.
(specialization_add): Adjust.
Diff:
---
ChangeLog.modules | 9 +++++++++
gcc/cp/cp-tree.h | 3 +--
gcc/cp/module.cc | 44 ++++++++++++++++++++++----------------------
gcc/cp/pt.c | 10 ++++------
4 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/ChangeLog.modules b/ChangeLog.modules
index dc1e41294a7..05dfd1383ea 100644
--- a/ChangeLog.modules
+++ b/ChangeLog.modules
@@ -1,8 +1,17 @@
2020-11-20 Nathan Sidwell <nathan@acm.org>
+<<<<<<< HEAD
gcc/
* doc/invoke.texi: Update
* doc/cppopts.texi: Update
+=======
+ gcc/cp/
+ * cp-tree.h (match_mergeable_specialization): Take a spec_entry.
+ * pt.c (match_mergeable_specialization): Likewise.
+ * module.cc (trees_in::decl_value): Adjust.
+ (trees_{in,out}::key_mergeable): Adjust.
+ (specialization_add): Adjust.
+>>>>>>> eecc1bc3517... Adjust template spec accessor
Merge trunk 5bba2215c23
c++: Template hash access (
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index c796bccf006..deb06629a03 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -7280,8 +7280,7 @@ extern void walk_specializations (bool,
void (*)(bool, spec_entry *,
void *),
void *);
-extern tree match_mergeable_specialization (bool is_decl, tree tmpl,
- tree args, tree spec,
+extern tree match_mergeable_specialization (bool is_decl, spec_entry *,
bool insert = true);
extern unsigned get_mergeable_specialization_flags (tree tmpl, tree spec);
extern void add_mergeable_specialization (tree tmpl, tree args,
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 5dade62a9e9..2c0a84712cf 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -8118,8 +8118,9 @@ trees_in::decl_value ()
{
/* Insert into type table. */
tree ti = DECL_TEMPLATE_INFO (inner);
- tree texist = match_mergeable_specialization
- (false, TI_TEMPLATE (ti), TI_ARGS (ti), TREE_TYPE (inner));
+ spec_entry elt =
+ {TI_TEMPLATE (ti), TI_ARGS (ti), TREE_TYPE (inner)};
+ tree texist = match_mergeable_specialization (false, &elt);
if (texist)
set_overrun ();
}
@@ -10350,16 +10351,14 @@ trees_out::key_mergeable (int tag, merge_kind mk, tree decl, tree inner,
{
/* Make sure we can locate the decl. */
tree existing = match_mergeable_specialization
- (bool (mk & MK_tmpl_decl_mask), entry->tmpl, entry->args,
- entry->spec, false);
+ (bool (mk & MK_tmpl_decl_mask), entry, false);
gcc_assert (existing);
if (mk & MK_tmpl_decl_mask)
{
if (mk & MK_tmpl_alias_mask)
/* It should be in both tables. */
- gcc_assert (match_mergeable_specialization
- (false, entry->tmpl, entry->args, entry->spec, false)
+ gcc_assert (match_mergeable_specialization (false, entry, false)
== TREE_TYPE (existing));
else if (mk & MK_tmpl_tmpl_mask)
if (tree ti = DECL_TEMPLATE_INFO (existing))
@@ -10670,21 +10669,22 @@ trees_in::key_mergeable (int tag, merge_kind mk, tree decl, tree inner,
if (mk & MK_template_mask)
{
- tree tmpl = tree_node ();
- tree args = tree_node ();
+ spec_entry spec;
+ spec.tmpl = tree_node ();
+ spec.args = tree_node ();
unsigned flags = u ();
- DECL_NAME (decl) = DECL_NAME (tmpl);
- DECL_CONTEXT (decl) = DECL_CONTEXT (tmpl);
+ DECL_NAME (decl) = DECL_NAME (spec.tmpl);
+ DECL_CONTEXT (decl) = DECL_CONTEXT (spec.tmpl);
DECL_NAME (inner) = DECL_NAME (decl);
DECL_CONTEXT (inner) = DECL_CONTEXT (decl);
- tree insert = decl;
+ spec.spec = decl;
if (mk & MK_tmpl_tmpl_mask)
{
if (inner == decl)
return error_mark_node;
- insert = inner;
+ spec.spec = inner;
}
tree constr = NULL_TREE;
bool is_decl = mk & MK_tmpl_decl_mask;
@@ -10701,16 +10701,15 @@ trees_in::key_mergeable (int tag, merge_kind mk, tree decl, tree inner,
{
if (mk == MK_type_spec && inner != decl)
return error_mark_node;
- insert = type;
+ spec.spec = type;
}
-
- existing = match_mergeable_specialization (is_decl, tmpl, args, insert);
+ existing = match_mergeable_specialization (is_decl, &spec);
if (constr)
/* We'll add these back later, if this is the new decl. */
remove_constraints (inner);
if (!existing)
- add_mergeable_specialization (tmpl, args, decl, flags);
+ add_mergeable_specialization (spec.tmpl, spec.args, decl, flags);
else if (mk & MK_tmpl_decl_mask)
{
/* A declaration specialization. */
@@ -10966,13 +10965,15 @@ trees_in::key_mergeable (int tag, merge_kind mk, tree decl, tree inner,
if (mk == MK_friend_spec)
{
- tree tmpl = tree_node ();
- tree args = tree_node ();
+ spec_entry spec;
+ spec.tmpl = tree_node ();
+ spec.args = tree_node ();
+ spec.spec = decl;
unsigned flags = u ();
- tree e = match_mergeable_specialization (true, tmpl, args, decl);
+ tree e = match_mergeable_specialization (true, &spec);
if (!e)
- add_mergeable_specialization (tmpl, args,
+ add_mergeable_specialization (spec.tmpl, spec.args,
existing ? existing : decl, flags);
else if (e != existing)
set_overrun ();
@@ -12871,8 +12872,7 @@ specialization_add (bool decl_p, spec_entry *entry, void *data_)
/* Only alias templates can appear in both tables (and
if they're in the type table they must also be in the decl table). */
gcc_checking_assert
- (!match_mergeable_specialization (true, entry->tmpl, entry->args,
- entry->spec, false)
+ (!match_mergeable_specialization (true, entry, false)
== (decl_p || !DECL_ALIAS_TEMPLATE_P (entry->tmpl)));
}
else if (VAR_OR_FUNCTION_DECL_P (entry->spec))
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d0e3cc10345..1dd6d6b0a00 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -29723,15 +29723,13 @@ walk_specializations (bool decls_p,
nothing). If INSERT is true, and there was nothing, add the new spec. */
tree
-match_mergeable_specialization (bool decl_p, tree tmpl, tree args, tree spec,
- bool insert)
+ match_mergeable_specialization (bool decl_p, spec_entry *elt, bool insert)
{
- spec_entry elt = {tmpl, args, spec};
hash_table<spec_hasher> *specializations
= decl_p ? decl_specializations : type_specializations;
- hashval_t hash = spec_hasher::hash (&elt);
+ hashval_t hash = spec_hasher::hash (elt);
spec_entry **slot
- = specializations->find_slot_with_hash (&elt, hash,
+ = specializations->find_slot_with_hash (elt, hash,
insert ? INSERT : NO_INSERT);
if (slot && *slot)
return (*slot)->spec;
@@ -29739,7 +29737,7 @@ match_mergeable_specialization (bool decl_p, tree tmpl, tree args, tree spec,
if (insert)
{
auto entry = ggc_alloc<spec_entry> ();
- *entry = elt;
+ *entry = *elt;
*slot = entry;
}
More information about the Gcc-cvs
mailing list