This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] implement generic debug() functions for wide_int's
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 18 Oct 2017 13:08:05 -0400
- Subject: [patch] implement generic debug() functions for wide_int's
- Authentication-results: sourceware.org; auth=none
It looks like the generic debug() function for wide_int's is missing.
Instead, we have a wi->dump() method. I have implemented debug() for
generic wide_int and for widest_int, which should cover the common
cases. Anything else, can continue using the ->dump() method
templated methods.
Also, do we have a blessed way of specifying overloaded functions in
ChangeLog's? I couldn't find anything in our GCC coding guidelines or
in the GNU coding guidelines. For lack of direction, I'm doing the
following:
* wide-int.cc (debug) [const wide_int &]: New.
(debug) [const wide_int *]: New.
(debug) [const widest_int &]: New.
(debug) [const widest_int *]: New.
It seems appropriate, as that is the GNU way of changelogs for a
conditional change to a function ???.
OK for trunk?
gcc/
* wide-int.cc (debug) [const wide_int &]: New.
(debug) [const wide_int *]: New.
(debug) [const widest_int &]: New.
(debug) [const widest_int *]: New.
diff --git a/gcc/wide-int.cc b/gcc/wide-int.cc
index 71e24ec22af..1a1a68c1943 100644
--- a/gcc/wide-int.cc
+++ b/gcc/wide-int.cc
@@ -2146,6 +2146,39 @@ template void generic_wide_int <wide_int_ref_storage <true> >::dump () const;
template void offset_int::dump () const;
template void widest_int::dump () const;
+/* We could add all the above ::dump variants here, but wide_int and
+ widest_int should handle the common cases. Besides, you can always
+ call the dump method directly. */
+
+DEBUG_FUNCTION void
+debug (const wide_int &ref)
+{
+ ref.dump ();
+}
+
+DEBUG_FUNCTION void
+debug (const wide_int *ptr)
+{
+ if (ptr)
+ debug (*ptr);
+ else
+ fprintf (stderr, "<nil>\n");
+}
+
+DEBUG_FUNCTION void
+debug (const widest_int &ref)
+{
+ ref.dump ();
+}
+
+DEBUG_FUNCTION void
+debug (const widest_int *ptr)
+{
+ if (ptr)
+ debug (*ptr);
+ else
+ fprintf (stderr, "<nil>\n");
+}
#if CHECKING_P