Modernization; no functional change intended.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r16-1831-g8ac43bfa380b5c.

gcc/analyzer/ChangeLog:
        * checker-event.cc (function_entry_event::get_meaning): Convert
        diagnostic_event::meaning enums to enum class.
        (cfg_edge_event::get_meaning): Likewise.
        (call_event::get_meaning): Likewise.
        (return_event::get_meaning): Likewise.
        (start_consolidated_cfg_edges_event::get_meaning): Likewise.
        (inlined_call_event::get_meaning): Likewise.
        (warning_event::get_meaning): Likewise.
        * sm-fd.cc (fd_diagnostic::get_meaning_for_state_change):
        Likewise.
        * sm-file.cc (file_diagnostic::get_meaning_for_state_change):
        Likewise.
        * sm-malloc.cc (malloc_diagnostic::get_meaning_for_state_change):
        Likewise.
        * sm-sensitive.cc
        (exposure_through_output_file::get_meaning_for_state_change):
        Likewise.
        * sm-taint.cc (taint_diagnostic::get_meaning_for_state_change):
        Likewise.
        * varargs.cc
        (va_list_sm_diagnostic::get_meaning_for_state_change): Likewise.

gcc/ChangeLog:
        * diagnostic-format-sarif.cc
        (sarif_builder::maybe_make_kinds_array): Convert
        diagnostic_event::meaning enums to enum class.
        * diagnostic-path-output.cc (path_label::get_text): Likewise.
        * diagnostic-path.cc
        (diagnostic_event::meaning::maybe_get_verb_str): Likewise.
        (diagnostic_event::meaning::maybe_get_noun_str): Likewise.
        (diagnostic_event::meaning::maybe_get_property_str): Likewise.
        * diagnostic-path.h (diagnostic_event::verb): Likewise.
        (diagnostic_event::noun): Likewise.
        (diagnostic_event::property): Likewise.
        (diagnostic_event::meaning): Likewise.

gcc/testsuite/ChangeLog:
        * gcc.dg/plugin/analyzer_gil_plugin.cc
        (gil_diagnostic::get_meaning_for_state_change): Convert
        diagnostic_event::meaning enums to enum class.

Signed-off-by: David Malcolm <dmalc...@redhat.com>
---
 gcc/analyzer/checker-event.cc                 | 18 +++---
 gcc/analyzer/sm-fd.cc                         |  8 +--
 gcc/analyzer/sm-file.cc                       |  8 +--
 gcc/analyzer/sm-malloc.cc                     |  8 +--
 gcc/analyzer/sm-sensitive.cc                  |  4 +-
 gcc/analyzer/sm-taint.cc                      |  4 +-
 gcc/analyzer/varargs.cc                       |  8 +--
 gcc/diagnostic-format-sarif.cc                |  6 +-
 gcc/diagnostic-path-output.cc                 |  2 +-
 gcc/diagnostic-path.cc                        | 44 ++++++-------
 gcc/diagnostic-path.h                         | 62 +++++++++----------
 .../gcc.dg/plugin/analyzer_gil_plugin.cc      |  8 +--
 12 files changed, 90 insertions(+), 90 deletions(-)

diff --git a/gcc/analyzer/checker-event.cc b/gcc/analyzer/checker-event.cc
index 04b66bf85d63..767e962589e0 100644
--- a/gcc/analyzer/checker-event.cc
+++ b/gcc/analyzer/checker-event.cc
@@ -398,7 +398,7 @@ function_entry_event::print_desc (pretty_printer &pp) const
 diagnostic_event::meaning
 function_entry_event::get_meaning () const
 {
-  return meaning (VERB_enter, NOUN_function);
+  return meaning (verb::enter, noun::function);
 }
 
 /* class state_change_event : public checker_event.  */
@@ -632,9 +632,9 @@ cfg_edge_event::get_meaning () const
 {
   const cfg_superedge& cfg_sedge = get_cfg_superedge ();
   if (cfg_sedge.true_value_p ())
-    return meaning (VERB_branch, PROPERTY_true);
+    return meaning (verb::branch, property::true_);
   else if (cfg_sedge.false_value_p ())
-    return meaning (VERB_branch, PROPERTY_false);
+    return meaning (verb::branch, property::false_);
   else
     return meaning ();
 }
@@ -880,7 +880,7 @@ call_event::print_desc (pretty_printer &pp) const
 diagnostic_event::meaning
 call_event::get_meaning () const
 {
-  return meaning (VERB_call, NOUN_function);
+  return meaning (verb::call, noun::function);
 }
 
 /* Override of checker_event::is_call_p for calls.  */
@@ -964,7 +964,7 @@ return_event::print_desc (pretty_printer &pp) const
 diagnostic_event::meaning
 return_event::get_meaning () const
 {
-  return meaning (VERB_return, NOUN_function);
+  return meaning (verb::return_, noun::function);
 }
 
 /* Override of checker_event::is_return_p for returns.  */
@@ -991,8 +991,8 @@ start_consolidated_cfg_edges_event::print_desc 
(pretty_printer &pp) const
 diagnostic_event::meaning
 start_consolidated_cfg_edges_event::get_meaning () const
 {
-  return meaning (VERB_branch,
-                 (m_edge_sense ? PROPERTY_true : PROPERTY_false));
+  return meaning (verb::branch,
+                 (m_edge_sense ? property::true_ : property::false_));
 }
 
 /* class inlined_call_event : public checker_event.  */
@@ -1012,7 +1012,7 @@ inlined_call_event::print_desc (pretty_printer &pp) const
 diagnostic_event::meaning
 inlined_call_event::get_meaning () const
 {
-  return meaning (VERB_call, NOUN_function);
+  return meaning (verb::call, noun::function);
 }
 
 /* class setjmp_event : public checker_event.  */
@@ -1252,7 +1252,7 @@ warning_event::print_desc (pretty_printer &pp) const
 diagnostic_event::meaning
 warning_event::get_meaning () const
 {
-  return meaning (VERB_danger, NOUN_unknown);
+  return meaning (verb::danger, noun::unknown);
 }
 
 const program_state *
diff --git a/gcc/analyzer/sm-fd.cc b/gcc/analyzer/sm-fd.cc
index 09c311594bab..3a9162fdb7d8 100644
--- a/gcc/analyzer/sm-fd.cc
+++ b/gcc/analyzer/sm-fd.cc
@@ -401,11 +401,11 @@ public:
            || change.m_new_state == m_sm.m_new_datagram_socket
            || change.m_new_state == m_sm.m_new_stream_socket
            || change.m_new_state == m_sm.m_new_unknown_socket))
-      return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
-                        diagnostic_event::NOUN_resource);
+      return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+                                       diagnostic_event::noun::resource);
     if (change.m_new_state == m_sm.m_closed)
-      return diagnostic_event::meaning (diagnostic_event::VERB_release,
-                        diagnostic_event::NOUN_resource);
+      return diagnostic_event::meaning (diagnostic_event::verb::release,
+                                       diagnostic_event::noun::resource);
     return diagnostic_event::meaning ();
   }
 
diff --git a/gcc/analyzer/sm-file.cc b/gcc/analyzer/sm-file.cc
index 61e24248c080..4b1fc7788763 100644
--- a/gcc/analyzer/sm-file.cc
+++ b/gcc/analyzer/sm-file.cc
@@ -161,11 +161,11 @@ public:
   {
     if (change.m_old_state == m_sm.get_start_state ()
        && change.m_new_state == m_sm.m_unchecked)
-      return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
-                                       diagnostic_event::NOUN_resource);
+      return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+                                       diagnostic_event::noun::resource);
     if (change.m_new_state == m_sm.m_closed)
-      return diagnostic_event::meaning (diagnostic_event::VERB_release,
-                                       diagnostic_event::NOUN_resource);
+      return diagnostic_event::meaning (diagnostic_event::verb::release,
+                                       diagnostic_event::noun::resource);
     return diagnostic_event::meaning ();
   }
 
diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc
index ee60b963b2b7..068d72f1c330 100644
--- a/gcc/analyzer/sm-malloc.cc
+++ b/gcc/analyzer/sm-malloc.cc
@@ -819,11 +819,11 @@ public:
   {
     if (change.m_old_state == m_sm.get_start_state ()
        && unchecked_p (change.m_new_state))
-      return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
-                                       diagnostic_event::NOUN_memory);
+      return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+                                       diagnostic_event::noun::memory);
     if (freed_p (change.m_new_state))
-      return diagnostic_event::meaning (diagnostic_event::VERB_release,
-                                       diagnostic_event::NOUN_memory);
+      return diagnostic_event::meaning (diagnostic_event::verb::release,
+                                       diagnostic_event::noun::memory);
     return diagnostic_event::meaning ();
   }
 
diff --git a/gcc/analyzer/sm-sensitive.cc b/gcc/analyzer/sm-sensitive.cc
index 7bd5ef68103f..f8fcdede8d8e 100644
--- a/gcc/analyzer/sm-sensitive.cc
+++ b/gcc/analyzer/sm-sensitive.cc
@@ -111,8 +111,8 @@ public:
     const final override
   {
     if (change.m_new_state == m_sm.m_sensitive)
-      return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
-                                       diagnostic_event::NOUN_sensitive);
+      return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+                                       diagnostic_event::noun::sensitive);
     return diagnostic_event::meaning ();
   }
   bool
diff --git a/gcc/analyzer/sm-taint.cc b/gcc/analyzer/sm-taint.cc
index e782081ac2d7..12b4e5d99801 100644
--- a/gcc/analyzer/sm-taint.cc
+++ b/gcc/analyzer/sm-taint.cc
@@ -214,8 +214,8 @@ public:
     const final override
   {
     if (change.m_new_state == m_sm.m_tainted)
-      return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
-                                       diagnostic_event::NOUN_taint);
+      return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+                                       diagnostic_event::noun::taint);
     return diagnostic_event::meaning ();
   }
 
diff --git a/gcc/analyzer/varargs.cc b/gcc/analyzer/varargs.cc
index 3b8f86364be4..44d567ac1650 100644
--- a/gcc/analyzer/varargs.cc
+++ b/gcc/analyzer/varargs.cc
@@ -339,11 +339,11 @@ public:
     const final override
   {
     if (change.m_new_state == m_sm.m_started)
-      return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
-                                       diagnostic_event::NOUN_resource);
+      return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+                                       diagnostic_event::noun::resource);
     if (change.m_new_state == m_sm.m_ended)
-      return diagnostic_event::meaning (diagnostic_event::VERB_release,
-                                       diagnostic_event::NOUN_resource);
+      return diagnostic_event::meaning (diagnostic_event::verb::release,
+                                       diagnostic_event::noun::resource);
     return diagnostic_event::meaning ();
   }
 
diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc
index d4ebe5a31edc..3fdc6134a1be 100644
--- a/gcc/diagnostic-format-sarif.cc
+++ b/gcc/diagnostic-format-sarif.cc
@@ -3005,9 +3005,9 @@ populate_thread_flow_location_object (sarif_result 
&result,
 std::unique_ptr<json::array>
 sarif_builder::maybe_make_kinds_array (diagnostic_event::meaning m) const
 {
-  if (m.m_verb == diagnostic_event::VERB_unknown
-      && m.m_noun == diagnostic_event::NOUN_unknown
-      && m.m_property == diagnostic_event::PROPERTY_unknown)
+  if (m.m_verb == diagnostic_event::verb::unknown
+      && m.m_noun == diagnostic_event::noun::unknown
+      && m.m_property == diagnostic_event::property::unknown)
     return nullptr;
 
   auto kinds_arr = std::make_unique<json::array> ();
diff --git a/gcc/diagnostic-path-output.cc b/gcc/diagnostic-path-output.cc
index bae24bf01a70..0a8931871c5d 100644
--- a/gcc/diagnostic-path-output.cc
+++ b/gcc/diagnostic-path-output.cc
@@ -114,7 +114,7 @@ class path_label : public range_label
     pp_printf (pp.get (), "%@", &event_id);
     pp_space (pp.get ());
 
-    if (meaning.m_verb == diagnostic_event::VERB_danger
+    if (meaning.m_verb == diagnostic_event::verb::danger
        && m_allow_emojis)
       {
        pp_unicode_character (pp.get (), 0x26A0); /* U+26A0 WARNING SIGN.  */
diff --git a/gcc/diagnostic-path.cc b/gcc/diagnostic-path.cc
index 0c617edeaa51..6af24ffea380 100644
--- a/gcc/diagnostic-path.cc
+++ b/gcc/diagnostic-path.cc
@@ -77,23 +77,23 @@ diagnostic_event::meaning::maybe_get_verb_str (enum verb v)
     {
     default:
       gcc_unreachable ();
-    case VERB_unknown:
-      return NULL;
-    case VERB_acquire:
+    case verb::unknown:
+      return nullptr;
+    case verb::acquire:
       return "acquire";
-    case VERB_release:
+    case verb::release:
       return "release";
-    case VERB_enter:
+    case verb::enter:
       return "enter";
-    case VERB_exit:
+    case verb::exit:
       return "exit";
-    case VERB_call:
+    case verb::call:
       return "call";
-    case VERB_return:
+    case verb::return_:
       return "return";
-    case VERB_branch:
+    case verb::branch:
       return "branch";
-    case VERB_danger:
+    case verb::danger:
       return "danger";
     }
 }
@@ -108,19 +108,19 @@ diagnostic_event::meaning::maybe_get_noun_str (enum noun 
n)
     {
     default:
       gcc_unreachable ();
-    case NOUN_unknown:
-      return NULL;
-    case NOUN_taint:
+    case noun::unknown:
+      return nullptr;
+    case noun::taint:
       return "taint";
-    case NOUN_sensitive:
+    case noun::sensitive:
       return "sensitive";
-    case NOUN_function:
+    case noun::function:
       return "function";
-    case NOUN_lock:
+    case noun::lock:
       return "lock";
-    case NOUN_memory:
+    case noun::memory:
       return "memory";
-    case NOUN_resource:
+    case noun::resource:
       return "resource";
     }
 }
@@ -135,11 +135,11 @@ diagnostic_event::meaning::maybe_get_property_str (enum 
property p)
     {
     default:
       gcc_unreachable ();
-    case PROPERTY_unknown:
-      return NULL;
-    case PROPERTY_true:
+    case property::unknown:
+      return nullptr;
+    case property::true_:
       return "true";
-    case PROPERTY_false:
+    case property::false_:
       return "false";
     }
 }
diff --git a/gcc/diagnostic-path.h b/gcc/diagnostic-path.h
index a3987a015a3e..e68f7681a5eb 100644
--- a/gcc/diagnostic-path.h
+++ b/gcc/diagnostic-path.h
@@ -75,59 +75,59 @@ class diagnostic_event
  public:
   /* Enums for giving a sense of what this event means.
      Roughly corresponds to SARIF v2.1.0 section 3.38.8.  */
-  enum verb
+  enum class verb
   {
-    VERB_unknown,
+    unknown,
 
-    VERB_acquire,
-    VERB_release,
-    VERB_enter,
-    VERB_exit,
-    VERB_call,
-    VERB_return,
-    VERB_branch,
+    acquire,
+    release,
+    enter,
+    exit,
+    call,
+    return_,
+    branch,
 
-    VERB_danger
+    danger
   };
-  enum noun
+  enum class noun
   {
-    NOUN_unknown,
-
-    NOUN_taint,
-    NOUN_sensitive, // this one isn't in SARIF v2.1.0; filed as 
https://github.com/oasis-tcs/sarif-spec/issues/530
-    NOUN_function,
-    NOUN_lock,
-    NOUN_memory,
-    NOUN_resource
+    unknown,
+
+    taint,
+    sensitive, // this one isn't in SARIF v2.1.0; filed as 
https://github.com/oasis-tcs/sarif-spec/issues/530
+    function,
+    lock,
+    memory,
+    resource
   };
-  enum property
+  enum class property
   {
-    PROPERTY_unknown,
+    unknown,
 
-    PROPERTY_true,
-    PROPERTY_false
+    true_,
+    false_
   };
   /* A bundle of such enums, allowing for descriptions of the meaning of
      an event, such as
-     - "acquire memory": meaning (VERB_acquire, NOUN_memory)
-     - "take true branch"": meaning (VERB_branch, PROPERTY_true)
-     - "return from function": meaning (VERB_return, NOUN_function)
+     - "acquire memory": meaning (verb::acquire, noun::memory)
+     - "take true branch"": meaning (verb::branch, property::true)
+     - "return from function": meaning (verb::return, noun::function)
      etc, as per SARIF's threadFlowLocation "kinds" property
      (SARIF v2.1.0 section 3.38.8).  */
   struct meaning
   {
     meaning ()
-    : m_verb (VERB_unknown),
-      m_noun (NOUN_unknown),
-      m_property (PROPERTY_unknown)
+    : m_verb (verb::unknown),
+      m_noun (noun::unknown),
+      m_property (property::unknown)
     {
     }
     meaning (enum verb verb, enum noun noun)
-    : m_verb (verb), m_noun (noun), m_property (PROPERTY_unknown)
+    : m_verb (verb), m_noun (noun), m_property (property::unknown)
     {
     }
     meaning (enum verb verb, enum property property)
-    : m_verb (verb), m_noun (NOUN_unknown), m_property (property)
+    : m_verb (verb), m_noun (noun::unknown), m_property (property)
     {
     }
 
diff --git a/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.cc 
b/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.cc
index 6f4cbc23c7b3..fa2f2fa01610 100644
--- a/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.cc
+++ b/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.cc
@@ -127,11 +127,11 @@ public:
     if (change.is_global_p ())
       {
        if (change.m_new_state == m_sm.m_released_gil)
-         return diagnostic_event::meaning (diagnostic_event::VERB_release,
-                                           diagnostic_event::NOUN_lock);
+         return diagnostic_event::meaning (diagnostic_event::verb::release,
+                                           diagnostic_event::noun::lock);
        else if (change.m_new_state == m_sm.get_start_state ())
-         return diagnostic_event::meaning (diagnostic_event::VERB_acquire,
-                                           diagnostic_event::NOUN_lock);
+         return diagnostic_event::meaning (diagnostic_event::verb::acquire,
+                                           diagnostic_event::noun::lock);
       }
     return diagnostic_event::meaning ();
   }
-- 
2.26.3

Reply via email to