Get rid of macros for diagnostic_report_current_module
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 5 May 2017 21:03:07 +0000 (21:03 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Fri, 5 May 2017 21:03:07 +0000 (21:03 +0000)
diagnostic.h has a couple of macros (diagnostic_last_module_changed
and diagnostic_set_last_module) which are only used within
diagnostic_report_current_module.

This patch eliminates the macros in favor of static functions within
diagnostic.c.

No functional change intended.

gcc/ChangeLog:
* diagnostic.c (last_module_changed_p): New function.
(set_last_module): New function.
(diagnostic_report_current_module): Convert macro usage to
the above functions.
* diagnostic.h (diagnostic_context::last_module): Strengthen
from const line_map * to const line_map_ordinary *.
(diagnostic_last_module_changed): Delete macro.
(diagnostic_set_last_module): Delete macro.

From-SVN: r247664

gcc/ChangeLog
gcc/diagnostic.c
gcc/diagnostic.h

index 72c8c9e..56ec279 100644 (file)
@@ -1,5 +1,16 @@
 2017-05-05  David Malcolm  <dmalcolm@redhat.com>
 
+       * diagnostic.c (last_module_changed_p): New function.
+       (set_last_module): New function.
+       (diagnostic_report_current_module): Convert macro usage to
+       the above functions.
+       * diagnostic.h (diagnostic_context::last_module): Strengthen
+       from const line_map * to const line_map_ordinary *.
+       (diagnostic_last_module_changed): Delete macro.
+       (diagnostic_set_last_module): Delete macro.
+
+2017-05-05  David Malcolm  <dmalcolm@redhat.com>
+
        * diagnostic.c (diagnostic_impl): Replace report_diagnostic
        with diagnostic_report_diagnostic.
        (diagnostic_n_impl_richloc): Likewise.
index 815bdb0..1585196 100644 (file)
@@ -534,6 +534,25 @@ diagnostic_action_after_output (diagnostic_context *context,
     }
 }
 
+/* True if the last module or file in which a diagnostic was reported is
+   different from the current one.  */
+
+static bool
+last_module_changed_p (diagnostic_context *context,
+                      const line_map_ordinary *map)
+{
+  return context->last_module != map;
+}
+
+/* Remember the current module or file as being the last one in which we
+   report a diagnostic.  */
+
+static void
+set_last_module (diagnostic_context *context, const line_map_ordinary *map)
+{
+  context->last_module = map;
+}
+
 void
 diagnostic_report_current_module (diagnostic_context *context, location_t where)
 {
@@ -552,9 +571,9 @@ diagnostic_report_current_module (diagnostic_context *context, location_t where)
                            LRK_MACRO_DEFINITION_LOCATION,
                            &map);
 
-  if (map && diagnostic_last_module_changed (context, map))
+  if (map && last_module_changed_p (context, map))
     {
-      diagnostic_set_last_module (context, map);
+      set_last_module (context, map);
       if (! MAIN_FILE_P (map))
        {
          map = INCLUDED_FROM (line_table, map);
index 846a158..89d5a08 100644 (file)
@@ -189,7 +189,7 @@ struct diagnostic_context
 
   /* Used to detect when the input file stack has changed since last
      described.  */
-  const struct line_map *last_module;
+  const line_map_ordinary *last_module;
 
   int lock;
 
@@ -241,16 +241,6 @@ diagnostic_inhibit_notes (diagnostic_context * context)
 /* Same as output_prefixing_rule.  Works on 'diagnostic_context *'.  */
 #define diagnostic_prefixing_rule(DC) ((DC)->printer->wrapping.rule)
 
-/* True if the last module or file in which a diagnostic was reported is
-   different from the current one.  */
-#define diagnostic_last_module_changed(DC, MAP)        \
-  ((DC)->last_module != MAP)
-
-/* Remember the current module or file as being the last one in which we
-   report a diagnostic.  */
-#define diagnostic_set_last_module(DC, MAP)    \
-  (DC)->last_module = MAP
-
 /* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher.  */
 #define diagnostic_abort_on_error(DC) \
   (DC)->abort_on_error = true