LCOV - code coverage report
Current view: top level - gcc - hash-map-traits.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 26 26
Test Date: 2026-02-28 14:20:25 Functions: 100.0 % 21 21
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* A hash map traits.
       2              :    Copyright (C) 2015-2026 Free Software Foundation, Inc.
       3              : 
       4              : This file is part of GCC.
       5              : 
       6              : GCC is free software; you can redistribute it and/or modify it under
       7              : the terms of the GNU General Public License as published by the Free
       8              : Software Foundation; either version 3, or (at your option) any later
       9              : version.
      10              : 
      11              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14              : for more details.
      15              : 
      16              : You should have received a copy of the GNU General Public License
      17              : along with GCC; see the file COPYING3.  If not see
      18              : <http://www.gnu.org/licenses/>.  */
      19              : 
      20              : #ifndef HASH_MAP_TRAITS_H
      21              : #define HASH_MAP_TRAITS_H
      22              : 
      23              : /* Bacause mem-stats.h uses default hashmap traits, we have to
      24              :    put the class to this separate header file.  */
      25              : 
      26              : #include "hash-traits.h"
      27              : 
      28              : /* Implement hash_map traits for a key with hash traits H.  Empty and
      29              :    deleted map entries are represented as empty and deleted keys.  */
      30              : 
      31              : template <typename H, typename Value>
      32              : struct simple_hashmap_traits
      33              : {
      34              :   typedef typename H::value_type key_type;
      35              :   static const bool maybe_mx = true;
      36              :   static inline hashval_t hash (const key_type &);
      37              :   static inline bool equal_keys (const key_type &, const key_type &);
      38              :   template <typename T> static inline void remove (T &);
      39              :   static const bool empty_zero_p = H::empty_zero_p;
      40              :   template <typename T> static inline bool is_empty (const T &);
      41              :   template <typename T> static inline bool is_deleted (const T &);
      42              :   template <typename T> static inline void mark_empty (T &);
      43              :   template <typename T> static inline void mark_deleted (T &);
      44              : };
      45              : 
      46              : template <typename H, typename Value>
      47              : inline hashval_t
      48  >16336*10^7 : simple_hashmap_traits <H, Value>::hash (const key_type &h)
      49              : {
      50  >17193*10^7 :   return H::hash (h);
      51              : }
      52              : 
      53              : template <typename H, typename Value>
      54              : inline bool
      55  >15635*10^7 : simple_hashmap_traits <H, Value>::equal_keys (const key_type &k1,
      56              :                                               const key_type &k2)
      57              : {
      58  >15777*10^7 :   return H::equal (k1, k2);
      59              : }
      60              : 
      61              : template <typename H, typename Value>
      62              : template <typename T>
      63              : inline void
      64    591014397 : simple_hashmap_traits <H, Value>::remove (T &entry)
      65              : {
      66    104096746 :   H::remove (entry.m_key);
      67    590881621 :   entry.m_value.~Value ();
      68      2898211 : }
      69              : 
      70              : template <typename H, typename Value>
      71              : template <typename T>
      72              : inline bool
      73  >74307*10^7 : simple_hashmap_traits <H, Value>::is_empty (const T &entry)
      74              : {
      75  >75779*10^7 :   return H::is_empty (entry.m_key);
      76              : }
      77              : 
      78              : template <typename H, typename Value>
      79              : template <typename T>
      80              : inline bool
      81  >20339*10^7 : simple_hashmap_traits <H, Value>::is_deleted (const T &entry)
      82              : {
      83   9821267029 :   return H::is_deleted (entry.m_key);
      84              : }
      85              : 
      86              : template <typename H, typename Value>
      87              : template <typename T>
      88              : inline void
      89   1671359688 : simple_hashmap_traits <H, Value>::mark_empty (T &entry)
      90              : {
      91   1671359688 :   H::mark_empty (entry.m_key);
      92              : }
      93              : 
      94              : template <typename H, typename Value>
      95              : template <typename T>
      96              : inline void
      97     23377615 : simple_hashmap_traits <H, Value>::mark_deleted (T &entry)
      98              : {
      99     23244839 :   H::mark_deleted (entry.m_key);
     100              : }
     101              : 
     102              : template <typename H, typename Value>
     103              : struct simple_cache_map_traits: public simple_hashmap_traits<H,Value>
     104              : {
     105              :   static const bool maybe_mx = false;
     106              : };
     107              : 
     108              : /* Implement traits for a hash_map with keys of type Key and values of
     109              :    type Value for cases in which the key cannot represent empty and
     110              :    deleted slots.  Instead record empty and deleted entries in Value.  */
     111              : 
     112              : template <typename Key, typename Value>
     113              : struct unbounded_hashmap_traits
     114              : {
     115              :   typedef typename Key::value_type key_type;
     116              : 
     117              :   static hashval_t hash (const typename Key::value_type &);
     118              :   static bool equal_keys (const typename Key::value_type &,
     119              :                           const typename Key::compare_type &);
     120              : 
     121              :   template <typename T> static inline void remove (T &);
     122              :   static const bool empty_zero_p = default_hash_traits <Value>::empty_zero_p;
     123              :   template <typename T> static inline bool is_empty (const T &);
     124              :   template <typename T> static inline bool is_deleted (const T &);
     125              :   template <typename T> static inline void mark_empty (T &);
     126              :   template <typename T> static inline void mark_deleted (T &);
     127              : };
     128              : 
     129              : template <typename Key, typename Value>
     130              : inline hashval_t
     131      4466560 : unbounded_hashmap_traits <Key, Value>
     132              : ::hash (const typename Key::value_type &key)
     133              : {
     134      4466560 :   return Key::hash (key);
     135              : }
     136              : 
     137              : template <typename Key, typename Value>
     138              : inline bool
     139      3938294 : unbounded_hashmap_traits <Key, Value>
     140              : ::equal_keys (const typename Key::value_type &x,
     141              :               const typename Key::compare_type &y)
     142              : {
     143      3938294 :   return Key::equal (x, y);
     144              : }
     145              : 
     146              : template <typename Key, typename Value>
     147              : template <typename T>
     148              : inline void
     149              : unbounded_hashmap_traits <Key, Value>::remove (T &entry)
     150              : {
     151              :   default_hash_traits <Value>::remove (entry.m_value);
     152              : }
     153              : 
     154              : template <typename Key, typename Value>
     155              : template <typename T>
     156              : inline bool
     157     26081022 : unbounded_hashmap_traits <Key, Value>::is_empty (const T &entry)
     158              : {
     159     26081022 :   return default_hash_traits <Value>::is_empty (entry.m_value);
     160              : }
     161              : 
     162              : template <typename Key, typename Value>
     163              : template <typename T>
     164              : inline bool
     165      4555159 : unbounded_hashmap_traits <Key, Value>::is_deleted (const T &entry)
     166              : {
     167       320859 :   return default_hash_traits <Value>::is_deleted (entry.m_value);
     168              : }
     169              : 
     170              : template <typename Key, typename Value>
     171              : template <typename T>
     172              : inline void
     173      8114795 : unbounded_hashmap_traits <Key, Value>::mark_empty (T &entry)
     174              : {
     175      8114795 :   default_hash_traits <Value>::mark_empty (entry.m_value);
     176              : }
     177              : 
     178              : template <typename Key, typename Value>
     179              : template <typename T>
     180              : inline void
     181              : unbounded_hashmap_traits <Key, Value>::mark_deleted (T &entry)
     182              : {
     183              :   default_hash_traits <Value>::mark_deleted (entry.m_value);
     184              : }
     185              : 
     186              : /* Implement traits for a hash_map from integer type Key to Value in
     187              :    cases where Key has no spare values for recording empty and deleted
     188              :    slots.  */
     189              : 
     190              : template <typename Key, typename Value>
     191              : using unbounded_int_hashmap_traits
     192              :   = unbounded_hashmap_traits <int_hash_base <Key>, Value>;
     193              : 
     194              : #endif // HASH_MAP_TRAITS_H
        

Generated by: LCOV version 2.4-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.