public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3636] analyzer: use std::unique_ptr for state machines from plugins
@ 2022-11-03 17:48 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2022-11-03 17:48 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e177be86c7d327b9abd2441d52e3f240b3a488cd

commit r13-3636-ge177be86c7d327b9abd2441d52e3f240b3a488cd
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Thu Nov 3 13:47:02 2022 -0400

    analyzer: use std::unique_ptr for state machines from plugins
    
    gcc/analyzer/ChangeLog:
            * analyzer.h: Use std::unique_ptr for state machines from plugins.
            * engine.cc: Likewise.
    
    gcc/testsuite/ChangeLog:
            * gcc.dg/plugin/analyzer_gil_plugin.c: Use std::unique_ptr for
            state machines from plugins.
    
    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

Diff:
---
 gcc/analyzer/analyzer.h                           | 2 +-
 gcc/analyzer/engine.cc                            | 4 ++--
 gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c | 3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/analyzer/analyzer.h b/gcc/analyzer/analyzer.h
index 88fdc1d04f0..c0041c35d1a 100644
--- a/gcc/analyzer/analyzer.h
+++ b/gcc/analyzer/analyzer.h
@@ -242,7 +242,7 @@ public:
 class plugin_analyzer_init_iface
 {
 public:
-  virtual void register_state_machine (state_machine *) = 0;
+  virtual void register_state_machine (std::unique_ptr<state_machine>) = 0;
   virtual void register_known_function (const char *name,
 					std::unique_ptr<known_function>) = 0;
   virtual logger *get_logger () const = 0;
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index fe17f8f76ce..9c32afc6c71 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -5953,10 +5953,10 @@ public:
     m_logger (logger)
   {}
 
-  void register_state_machine (state_machine *sm) final override
+  void register_state_machine (std::unique_ptr<state_machine> sm) final override
   {
     LOG_SCOPE (m_logger);
-    m_checkers->safe_push (sm);
+    m_checkers->safe_push (sm.release ());
   }
 
   void register_known_function (const char *name,
diff --git a/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c b/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c
index cf0baa5670d..b72856bf6f6 100644
--- a/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c
@@ -410,7 +410,8 @@ gil_analyzer_init_cb (void *gcc_data, void */*user_data*/)
   LOG_SCOPE (iface->get_logger ());
   if (0)
     inform (input_location, "got here: gil_analyzer_init_cb");
-  iface->register_state_machine (new gil_state_machine (iface->get_logger ()));
+  iface->register_state_machine
+    (make_unique<gil_state_machine> (iface->get_logger ()));
 }
 
 } // namespace ana

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-03 17:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 17:48 [gcc r13-3636] analyzer: use std::unique_ptr for state machines from plugins David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).