This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 19/22] gcc-rich-location.[ch]: add debug methods for cpp_string_location
- From: David Malcolm <dmalcolm at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Thu, 10 Sep 2015 16:28:30 -0400
- Subject: [PATCH 19/22] gcc-rich-location.[ch]: add debug methods for cpp_string_location
- Authentication-results: sourceware.org; auth=none
- References: <1441916913-11547-1-git-send-email-dmalcolm at redhat dot com>
gcc/ChangeLog:
* gcc-rich-location.c (cpp_string_fragment_location::debug): New.
(cpp_string_location::debug): New.
---
gcc/gcc-rich-location.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/gcc/gcc-rich-location.c b/gcc/gcc-rich-location.c
index 003e8f0..ae0b3bb 100644
--- a/gcc/gcc-rich-location.c
+++ b/gcc/gcc-rich-location.c
@@ -190,3 +190,29 @@ gcc_rich_location::expand_caption_va (diagnostic_context *context,
pp_clear_output_area (pp);
return result;
}
+
+/* Debugging method. Print a diagnostic showing the given fragment. */
+
+void
+cpp_string_fragment_location::debug (const char *msg) const
+{
+ rich_location richloc (get_covered_range ());
+ inform_at_rich_loc (&richloc, "%s", msg);
+}
+
+/* Debugging method. Print diagnostic showings the fragment(s) that make
+ up the cpp_string_location. */
+
+void
+cpp_string_location::debug () const
+{
+ char buf[64];
+ for (unsigned int i = 0; i < m_num_fraglocs; i++)
+ {
+ cpp_string_fragment_location *fragment = &m_fragloc_array[i];
+ snprintf (buf, sizeof (buf),
+ "fragment %i; %i cols per char",
+ i, fragment->m_cols_per_char);
+ fragment->debug (buf);
+ }
+}
--
1.8.5.3