diff gcc/hash-set.h @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line diff
--- a/gcc/hash-set.h	Fri Oct 27 22:46:09 2017 +0900
+++ b/gcc/hash-set.h	Thu Oct 25 07:37:49 2018 +0900
@@ -1,5 +1,5 @@
 /* A type-safe hash set.
-   Copyright (C) 2014-2017 Free Software Foundation, Inc.
+   Copyright (C) 2014-2018 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -80,6 +80,10 @@
 
   size_t elements () const { return m_table.elements (); }
 
+  /* Clear the hash table.  */
+
+  void empty () { m_table.empty (); }
+
   class iterator
   {
   public:
@@ -123,6 +127,44 @@
   hash_table<Traits> m_table;
 };
 
+/* Generic hash_set<TYPE> debug helper.
+
+   This needs to be instantiated for each hash_set<TYPE> used throughout
+   the compiler like this:
+
+    DEFINE_DEBUG_HASH_SET (TYPE)
+
+   The reason we have a debug_helper() is because GDB can't
+   disambiguate a plain call to debug(some_hash), and it must be called
+   like debug<TYPE>(some_hash).  */
+template<typename T>
+void
+debug_helper (hash_set<T> &ref)
+{
+  for (typename hash_set<T>::iterator it = ref.begin ();
+       it != ref.end (); ++it)
+    {
+      debug_slim (*it);
+      fputc ('\n', stderr);
+    }
+}
+
+#define DEFINE_DEBUG_HASH_SET(T) \
+  template void debug_helper (hash_set<T> &);		\
+  DEBUG_FUNCTION void					\
+  debug (hash_set<T> &ref)				\
+  {							\
+    debug_helper <T> (ref);				\
+  }							\
+  DEBUG_FUNCTION void					\
+  debug (hash_set<T> *ptr)				\
+  {							\
+    if (ptr)						\
+      debug (*ptr);					\
+    else						\
+      fprintf (stderr, "<nil>\n");			\
+  }
+
 /* ggc marking routines.  */
 
 template<typename K, typename H>