diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-12-08 10:38:10 -0800 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-12-08 10:41:15 -0800 |
commit | dded5f78ccb785520804444871a7b6ca4b735370 (patch) | |
tree | ce07f49d461a256bf322fa2e9be7ad3bf439905b /gcc/cp/pt.c | |
parent | 5312fa0fd95aab112abe40f2a5cdb70a76e89fbf (diff) | |
download | gcc-dded5f78ccb785520804444871a7b6ca4b735370.zip gcc-dded5f78ccb785520804444871a7b6ca4b735370.tar.gz gcc-dded5f78ccb785520804444871a7b6ca4b735370.tar.bz2 |
c++: template and clone fns for modules
We need to expose build_cdtor_clones, it fortunately has the desired
API -- gosh, how did that happen? :) The template machinery will need
to cache path-of-instantiation information, so add two more fields to
the tinst_level struct. I also had to adjust the
match_mergeable_specialization API since adding it, so including that
change too.
gcc/cp/
* cp-tree.h (struct tinst_level): Add path & visible fields.
(build_cdtor_clones): Declare.
(match_mergeable_specialization): Use a spec_entry, add insert parm.
* class.c (build_cdtor_clones): Externalize.
* pt.c (push_tinst_level_loc): Clear new fields.
(match_mergeable_specialization): Adjust API.
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2d3ab92..56d7b56 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1704,10 +1704,11 @@ register_specialization (tree spec, tree tmpl, tree args, bool is_friend, return spec; } -/* Returns true iff two spec_entry nodes are equivalent. */ - +/* Restricts tree and type comparisons. */ int comparing_specializations; +/* Returns true iff two spec_entry nodes are equivalent. */ + bool spec_hasher::equal (spec_entry *e1, spec_entry *e2) { @@ -10909,6 +10910,7 @@ push_tinst_level_loc (tree tldcl, tree targs, location_t loc) new_level->errors = errorcount + sorrycount; new_level->next = NULL; new_level->refcount = 0; + new_level->path = new_level->visible = nullptr; set_refcount_ptr (new_level->next, current_tinst_level); set_refcount_ptr (current_tinst_level, new_level); @@ -29668,29 +29670,27 @@ walk_specializations (bool decls_p, fn (decls_p, *iter, data); } -/* Lookup the specialization of TMPL, ARGS in the decl or type - specialization table. Return what's there, or if SPEC is non-null, - add it and return NULL. */ +/* Lookup the specialization of *ELT, in the decl or type + specialization table. Return the SPEC that's already there (NULL if + 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) +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, - spec ? INSERT : NO_INSERT); - spec_entry *entry = slot ? *slot: NULL; - - if (entry) - return entry->spec; + = specializations->find_slot_with_hash (elt, hash, + insert ? INSERT : NO_INSERT); + if (slot && *slot) + return (*slot)->spec; - if (spec) + if (insert) { - entry = ggc_alloc<spec_entry> (); - *entry = elt; + auto entry = ggc_alloc<spec_entry> (); + *entry = *elt; *slot = entry; } |