[gcc r13-714] analyzer: use 'final' and 'override' where appropriate

David Malcolm dmalcolm@gcc.gnu.org
Mon May 23 19:08:52 GMT 2022


https://gcc.gnu.org/g:2ac1459f044ee5a6ec5aee53a87fd3b8974a77f5

commit r13-714-g2ac1459f044ee5a6ec5aee53a87fd3b8974a77f5
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Mon May 23 15:08:13 2022 -0400

    analyzer: use 'final' and 'override' where appropriate
    
    gcc/analyzer/ChangeLog:
            * call-info.cc: Add "final" and "override" to all vfunc
            implementations that were missing them, as appropriate.
            * engine.cc: Likewise.
            * region-model.cc: Likewise.
            * sm-malloc.cc: Likewise.
            * supergraph.h: Likewise.
            * svalue.cc: Likewise.
            * varargs.cc: Likewise.
    
    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

Diff:
---
 gcc/analyzer/call-info.cc    |  2 +-
 gcc/analyzer/engine.cc       | 10 +++++-----
 gcc/analyzer/region-model.cc |  2 +-
 gcc/analyzer/sm-malloc.cc    |  6 ++++--
 gcc/analyzer/supergraph.h    |  3 ++-
 gcc/analyzer/svalue.cc       |  4 ++--
 gcc/analyzer/varargs.cc      |  2 +-
 7 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/gcc/analyzer/call-info.cc b/gcc/analyzer/call-info.cc
index 2d3fe0a790b..b3ff51e7460 100644
--- a/gcc/analyzer/call-info.cc
+++ b/gcc/analyzer/call-info.cc
@@ -96,7 +96,7 @@ call_info::add_events_to_path (checker_path *emission_path,
 	m_call_info (call_info)
     {}
 
-    label_text get_desc (bool can_colorize) const
+    label_text get_desc (bool can_colorize) const final override
     {
       return m_call_info->get_desc (can_colorize);
     }
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index c59374be81a..5ccfedf9a44 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -328,7 +328,7 @@ public:
   }
 
   state_machine::state_t get_state (const gimple *stmt ATTRIBUTE_UNUSED,
-				    tree var)
+				    tree var) final override
   {
     logger * const logger = get_logger ();
     LOG_FUNC (logger);
@@ -342,7 +342,7 @@ public:
     return current;
   }
   state_machine::state_t get_state (const gimple *stmt ATTRIBUTE_UNUSED,
-				    const svalue *sval)
+				    const svalue *sval) final override
   {
     logger * const logger = get_logger ();
     LOG_FUNC (logger);
@@ -355,7 +355,7 @@ public:
   void set_next_state (const gimple *stmt,
 		       tree var,
 		       state_machine::state_t to,
-		       tree origin)
+		       tree origin) final override
   {
     logger * const logger = get_logger ();
     LOG_FUNC (logger);
@@ -384,7 +384,7 @@ public:
   void set_next_state (const gimple *stmt,
 		       const svalue *sval,
 		       state_machine::state_t to,
-		       tree origin)
+		       tree origin) final override
   {
     logger * const logger = get_logger ();
     LOG_FUNC (logger);
@@ -1597,7 +1597,7 @@ public:
     return false;
   }
 
-  label_text describe_final_event (const evdesc::final_event &ev)
+  label_text describe_final_event (const evdesc::final_event &ev) final override
   {
     if (m_stack_pop_event)
       return ev.formatted_print
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 6f6a061cf75..6b49719d521 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -1640,7 +1640,7 @@ public:
 
   const char *get_kind () const final override { return "reason_attr_access"; }
 
-  void emit () const
+  void emit () const final override
   {
     inform (DECL_SOURCE_LOCATION (m_callee_fndecl),
 	    "parameter %i of %qD marked with attribute %qs",
diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc
index abdce6b0e7e..3c0f8902075 100644
--- a/gcc/analyzer/sm-malloc.cc
+++ b/gcc/analyzer/sm-malloc.cc
@@ -1015,7 +1015,8 @@ public:
 
   const char *get_kind () const final override { return "possible_null_arg"; }
 
-  bool subclass_equal_p (const pending_diagnostic &base_other) const
+  bool subclass_equal_p (const pending_diagnostic &base_other)
+    const final override
   {
     const possible_null_arg &sub_other
       = (const possible_null_arg &)base_other;
@@ -1119,7 +1120,8 @@ public:
 
   const char *get_kind () const final override { return "null_arg"; }
 
-  bool subclass_equal_p (const pending_diagnostic &base_other) const
+  bool subclass_equal_p (const pending_diagnostic &base_other)
+    const final override
   {
     const null_arg &sub_other
       = (const null_arg &)base_other;
diff --git a/gcc/analyzer/supergraph.h b/gcc/analyzer/supergraph.h
index cc53fcb7f24..42c6df57435 100644
--- a/gcc/analyzer/supergraph.h
+++ b/gcc/analyzer/supergraph.h
@@ -308,7 +308,8 @@ class superedge : public dedge<supergraph_traits>
 
   void dump (pretty_printer *pp) const;
   void dump () const;
-  void dump_dot (graphviz_out *gv, const dump_args_t &args) const;
+  void dump_dot (graphviz_out *gv, const dump_args_t &args)
+    const final override;
 
   virtual void dump_label_to_pp (pretty_printer *pp,
 				 bool user_facing) const = 0;
diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc
index ed289c6fc31..2f9149412b9 100644
--- a/gcc/analyzer/svalue.cc
+++ b/gcc/analyzer/svalue.cc
@@ -600,13 +600,13 @@ public:
   involvement_visitor (const svalue *needle)
   : m_needle (needle), m_found (false) {}
 
-  void visit_initial_svalue (const initial_svalue *candidate)
+  void visit_initial_svalue (const initial_svalue *candidate) final override
   {
     if (candidate == m_needle)
       m_found = true;
   }
 
-  void visit_conjured_svalue (const conjured_svalue *candidate)
+  void visit_conjured_svalue (const conjured_svalue *candidate) final override
   {
     if (candidate == m_needle)
       m_found = true;
diff --git a/gcc/analyzer/varargs.cc b/gcc/analyzer/varargs.cc
index 3f15adaf2fc..2d27484c0e1 100644
--- a/gcc/analyzer/varargs.cc
+++ b/gcc/analyzer/varargs.cc
@@ -466,7 +466,7 @@ public:
     return va_list_sm_diagnostic::subclass_equal_p (other);
   }
 
-  bool emit (rich_location *rich_loc)
+  bool emit (rich_location *rich_loc) final override
   {
     auto_diagnostic_group d;
     return warning_at (rich_loc, get_controlling_option (),


More information about the Gcc-cvs mailing list