From 73347e599fb93f4d6fd508d5bb3ef155fd8dabfb Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 25 Sep 2019 19:44:14 -0400
Subject: [PATCH 121/124] FIXME: rename event_id_t to diagnostic_event_id_t and
 move to diagnostic-path.h

---
 gcc/analyzer/impl-4.cc            |  7 ++++---
 gcc/analyzer/pending-diagnostic.h | 29 ++---------------------------
 gcc/analyzer/sm-file.cc           |  4 ++--
 gcc/analyzer/sm-malloc.cc         | 10 +++++-----
 gcc/diagnostic-path.h             | 25 +++++++++++++++++++++++++
 5 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/gcc/analyzer/impl-4.cc b/gcc/analyzer/impl-4.cc
index deef874..fc86eeb 100644
--- a/gcc/analyzer/impl-4.cc
+++ b/gcc/analyzer/impl-4.cc
@@ -1743,7 +1743,8 @@ public:
     return result;
   }
 
-  void prepare_for_emission (pending_diagnostic *pd, event_id_t emission_id)
+  void prepare_for_emission (pending_diagnostic *pd,
+			     diagnostic_event_id_t emission_id)
   {
     m_pending_diagnostic = pd;
     m_emission_id = emission_id;
@@ -1767,7 +1768,7 @@ public:
   tree m_fndecl;
   int m_depth;
   pending_diagnostic *m_pending_diagnostic;
-  event_id_t m_emission_id; // only set once all pruning has occurred
+  diagnostic_event_id_t m_emission_id; // only set once all pruning has occurred
 };
 
 /* A purely textual event, for use in debugging path creation and filtering.  */
@@ -2375,7 +2376,7 @@ public:
     checker4_event *e;
     int i;
     FOR_EACH_VEC_ELT (m_events, i, e)
-      e->prepare_for_emission (pd, event_id_t (i));
+      e->prepare_for_emission (pd, diagnostic_event_id_t (i));
   }
 
   ////////////////////////////////////////////////////////////////////////////
diff --git a/gcc/analyzer/pending-diagnostic.h b/gcc/analyzer/pending-diagnostic.h
index 2e434e7..138f6ee 100644
--- a/gcc/analyzer/pending-diagnostic.h
+++ b/gcc/analyzer/pending-diagnostic.h
@@ -36,31 +36,6 @@ class metadata : public diagnostic_metadata
  private:
 };
 
-/* A class for referring to events within a diagnostic_path.
-   They are stored as 0-based offsets into the events, but
-   printed as 1-based numbers.  For example, a 3-event path
-   has event offsets 0, 1, and 2, which would be shown to
-   the user as "(1)", "(2)" and "(3)".  */
-
-class event_id_t
-{
- public:
-  event_id_t () : m_index (UNKNOWN_EVENT_IDX) {}
-  event_id_t (int zero_based_idx) : m_index (zero_based_idx) {}
-
-  bool known_p () const { return m_index != UNKNOWN_EVENT_IDX; }
-
-  int one_based () const
-  {
-    gcc_assert (known_p ());
-    return m_index + 1;
-  }
-
- private:
-  static const int UNKNOWN_EVENT_IDX = -1;
-  int m_index; // zero-based
-};
-
 /* Various bundles of information used for generating more precise
    messages for events within a diagnostic_path, for passing to the
    various "describe_*" vfuncs of pending_diagnostic.  See those
@@ -87,7 +62,7 @@ struct state_change : public event_desc
 		tree origin,
 		state_machine::state_t old_state,
 		state_machine::state_t new_state,
-		event_id_t event_id)
+		diagnostic_event_id_t event_id)
   : event_desc (colorize),
     m_expr (expr), m_origin (origin),
     m_old_state (old_state), m_new_state (new_state),
@@ -98,7 +73,7 @@ struct state_change : public event_desc
   tree m_origin;
   state_machine::state_t m_old_state;
   state_machine::state_t m_new_state;
-  event_id_t m_event_id;
+  diagnostic_event_id_t m_event_id;
 };
 
 /* For use by pending_diagnostic::describe_call_with_state.  */
diff --git a/gcc/analyzer/sm-file.cc b/gcc/analyzer/sm-file.cc
index faa67fa..e905062 100644
--- a/gcc/analyzer/sm-file.cc
+++ b/gcc/analyzer/sm-file.cc
@@ -167,7 +167,7 @@ public:
   }
 
 private:
-  event_id_t m_first_fclose_event;
+  diagnostic_event_id_t m_first_fclose_event;
 };
 
 class file_leak : public file_diagnostic
@@ -211,7 +211,7 @@ public:
   }
 
 private:
-  event_id_t m_fopen_event;
+  diagnostic_event_id_t m_fopen_event;
 };
 
 ////////////////////////////////////////////////////////////////////////////
diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc
index aece3a1..72dd724 100644
--- a/gcc/analyzer/sm-malloc.cc
+++ b/gcc/analyzer/sm-malloc.cc
@@ -154,7 +154,7 @@ public:
     if (!rich_loc->get_path ())
       return;
 
-    event_id_t second_free_event
+    diagnostic_event_id_t second_free_event
       = rich_loc->get_path ()->get_final_event_id ();
 
     if (m_first_free_event.known_p ()
@@ -206,7 +206,7 @@ public:
 #endif
 
 private:
-  event_id_t m_first_free_event;
+  diagnostic_event_id_t m_first_free_event;
 };
 
 /* Abstract subclass for describing possible bad uses of NULL.
@@ -241,7 +241,7 @@ public:
   }
 
 protected:
-  event_id_t m_origin_of_unchecked_event;
+  diagnostic_event_id_t m_origin_of_unchecked_event;
 };
 
 /* Concrete subclass for describing dereference of a possible NULL
@@ -473,7 +473,7 @@ public:
   }
 
 private:
-  event_id_t m_free_event;
+  diagnostic_event_id_t m_free_event;
 };
 
 class malloc_leak : public malloc_diagnostic
@@ -513,7 +513,7 @@ public:
   }
 
 private:
-  event_id_t m_malloc_event;
+  diagnostic_event_id_t m_malloc_event;
 };
 
 class free_of_non_heap : public malloc_diagnostic
diff --git a/gcc/diagnostic-path.h b/gcc/diagnostic-path.h
index 87986b2..f318677 100644
--- a/gcc/diagnostic-path.h
+++ b/gcc/diagnostic-path.h
@@ -140,6 +140,31 @@ class simple_diagnostic_path : public diagnostic_path
   pretty_printer *m_event_pp;
 };
 
+/* A class for referring to events within a diagnostic_path.
+   They are stored as 0-based offsets into the events, but
+   printed as 1-based numbers.  For example, a 3-event path
+   has event offsets 0, 1, and 2, which would be shown to
+   the user as "(1)", "(2)" and "(3)".  */
+
+class diagnostic_event_id_t
+{
+ public:
+  diagnostic_event_id_t () : m_index (UNKNOWN_EVENT_IDX) {}
+  diagnostic_event_id_t (int zero_based_idx) : m_index (zero_based_idx) {}
+
+  bool known_p () const { return m_index != UNKNOWN_EVENT_IDX; }
+
+  int one_based () const
+  {
+    gcc_assert (known_p ());
+    return m_index + 1;
+  }
+
+ private:
+  static const int UNKNOWN_EVENT_IDX = -1;
+  int m_index; // zero-based
+};
+
 // FIXME:
 void debug (diagnostic_path *path);
 
-- 
1.8.5.3

