diff options
author | David Malcolm <dmalcolm@redhat.com> | 2019-12-10 21:18:23 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2020-01-14 12:44:04 -0500 |
commit | 7ca50de02cf12c759f4f8daf60913704782b7d45 (patch) | |
tree | ca8340987edc24222001b551b1eda85777104e74 /gcc/hash-map-tests.c | |
parent | 8982b5535c2762f566fd15e5862acf4702a78690 (diff) | |
download | gcc-7ca50de02cf12c759f4f8daf60913704782b7d45.zip gcc-7ca50de02cf12c759f4f8daf60913704782b7d45.tar.gz gcc-7ca50de02cf12c759f4f8daf60913704782b7d45.tar.bz2 |
hash-table.h: support non-zero empty values in empty_slow (v2)
gcc/cp/ChangeLog:
* cp-gimplify.c (source_location_table_entry_hash::empty_zero_p):
New static constant.
* cp-tree.h (named_decl_hash::empty_zero_p): Likewise.
(struct named_label_hash::empty_zero_p): Likewise.
* decl2.c (mangled_decl_hash::empty_zero_p): Likewise.
gcc/ChangeLog:
* attribs.c (excl_hash_traits::empty_zero_p): New static constant.
* gcov.c (function_start_pair_hash::empty_zero_p): Likewise.
* graphite.c (struct sese_scev_hash::empty_zero_p): Likewise.
* hash-map-tests.c (selftest::test_nonzero_empty_key): New selftest.
(selftest::hash_map_tests_c_tests): Call it.
* hash-map-traits.h (simple_hashmap_traits::empty_zero_p):
New static constant, using the value of = H::empty_zero_p.
(unbounded_hashmap_traits::empty_zero_p): Likewise, using the value
from default_hash_traits <Value>.
* hash-map.h (hash_map::empty_zero_p): Likewise, using the value
from Traits.
* hash-set-tests.c (value_hash_traits::empty_zero_p): Likewise.
* hash-table.h (hash_table::alloc_entries): Guard the loop of
calls to mark_empty with !Descriptor::empty_zero_p.
(hash_table::empty_slow): Conditionalize the memset call with a
check that Descriptor::empty_zero_p; otherwise, loop through the
entries calling mark_empty on them.
* hash-traits.h (int_hash::empty_zero_p): New static constant.
(pointer_hash::empty_zero_p): Likewise.
(pair_hash::empty_zero_p): Likewise.
* ipa-devirt.c (default_hash_traits <type_pair>::empty_zero_p):
Likewise.
* ipa-prop.c (ipa_bit_ggc_hash_traits::empty_zero_p): Likewise.
(ipa_vr_ggc_hash_traits::empty_zero_p): Likewise.
* profile.c (location_triplet_hash::empty_zero_p): Likewise.
* sanopt.c (sanopt_tree_triplet_hash::empty_zero_p): Likewise.
(sanopt_tree_couple_hash::empty_zero_p): Likewise.
* tree-hasher.h (int_tree_hasher::empty_zero_p): Likewise.
* tree-ssa-sccvn.c (vn_ssa_aux_hasher::empty_zero_p): Likewise.
* tree-vect-slp.c (bst_traits::empty_zero_p): Likewise.
* tree-vectorizer.h
(default_hash_traits<scalar_cond_masked_key>::empty_zero_p):
Likewise.
Diffstat (limited to 'gcc/hash-map-tests.c')
-rw-r--r-- | gcc/hash-map-tests.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/hash-map-tests.c b/gcc/hash-map-tests.c index 743fb26..63574029 100644 --- a/gcc/hash-map-tests.c +++ b/gcc/hash-map-tests.c @@ -280,6 +280,27 @@ test_map_of_type_with_ctor_and_dtor () } } +/* Test calling empty on a hash_map that has a key type with non-zero + "empty" value. */ + +static void +test_nonzero_empty_key () +{ + typedef int_hash<int, INT_MIN, INT_MAX> IntHash; + hash_map<int, int, simple_hashmap_traits<IntHash, int> > x; + + for (int i = 1; i != 32; ++i) + x.put (i, i); + + ASSERT_EQ (x.get (0), NULL); + ASSERT_EQ (*x.get (1), 1); + + x.empty (); + + ASSERT_EQ (x.get (0), NULL); + ASSERT_EQ (x.get (1), NULL); +} + /* Run all of the selftests within this file. */ void @@ -288,6 +309,7 @@ hash_map_tests_c_tests () test_map_of_strings_to_int (); test_map_of_int_to_strings (); test_map_of_type_with_ctor_and_dtor (); + test_nonzero_empty_key (); } } // namespace selftest |