aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2022-11-03 13:47:02 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2022-11-03 13:47:02 -0400
commit76dd2c4f2d46f16e8f9a89487e5b3c2b7d4a1369 (patch)
tree6d581c48f99c8f8b4524687a4dca356d0ff9f3ba /gcc
parentaccece8c9543e4f3f7bbf24989755dd0453658b7 (diff)
downloadgcc-76dd2c4f2d46f16e8f9a89487e5b3c2b7d4a1369.zip
gcc-76dd2c4f2d46f16e8f9a89487e5b3c2b7d4a1369.tar.gz
gcc-76dd2c4f2d46f16e8f9a89487e5b3c2b7d4a1369.tar.bz2
analyzer: use std::unique_ptr for known functions
gcc/analyzer/ChangeLog: * analyzer.h: Use std::unique_ptr for known functions. * engine.cc: Likewise. * known-function-manager.cc: Likewise. * known-function-manager.h: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/analyzer_kernel_plugin.c: Use std::unique_ptr for known functions. * gcc.dg/plugin/analyzer_known_fns_plugin.c: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/analyzer/analyzer.h2
-rw-r--r--gcc/analyzer/engine.cc4
-rw-r--r--gcc/analyzer/known-function-manager.cc5
-rw-r--r--gcc/analyzer/known-function-manager.h2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/analyzer_kernel_plugin.c7
-rw-r--r--gcc/testsuite/gcc.dg/plugin/analyzer_known_fns_plugin.c7
6 files changed, 15 insertions, 12 deletions
diff --git a/gcc/analyzer/analyzer.h b/gcc/analyzer/analyzer.h
index d8d3e78..88fdc1d 100644
--- a/gcc/analyzer/analyzer.h
+++ b/gcc/analyzer/analyzer.h
@@ -244,7 +244,7 @@ class plugin_analyzer_init_iface
public:
virtual void register_state_machine (state_machine *) = 0;
virtual void register_known_function (const char *name,
- known_function *) = 0;
+ 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 d770c6f..fe17f8f 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -5960,10 +5960,10 @@ public:
}
void register_known_function (const char *name,
- known_function *kf) final override
+ std::unique_ptr<known_function> kf) final override
{
LOG_SCOPE (m_logger);
- m_known_fn_mgr->add (name, kf);
+ m_known_fn_mgr->add (name, std::move (kf));
}
logger *get_logger () const final override
diff --git a/gcc/analyzer/known-function-manager.cc b/gcc/analyzer/known-function-manager.cc
index 42dfe3a..7341b06 100644
--- a/gcc/analyzer/known-function-manager.cc
+++ b/gcc/analyzer/known-function-manager.cc
@@ -48,11 +48,12 @@ known_function_manager::~known_function_manager ()
}
void
-known_function_manager::add (const char *name, known_function *kf)
+known_function_manager::add (const char *name,
+ std::unique_ptr<known_function> kf)
{
LOG_FUNC_1 (get_logger (), "registering %s", name);
tree id = get_identifier (name);
- m_map_id_to_kf.put (id, kf);
+ m_map_id_to_kf.put (id, kf.release ());
}
const known_function *
diff --git a/gcc/analyzer/known-function-manager.h b/gcc/analyzer/known-function-manager.h
index 2b95b7e..daf1bc5 100644
--- a/gcc/analyzer/known-function-manager.h
+++ b/gcc/analyzer/known-function-manager.h
@@ -30,7 +30,7 @@ class known_function_manager : public log_user
public:
known_function_manager (logger *logger);
~known_function_manager ();
- void add (const char *name, known_function *kf);
+ void add (const char *name, std::unique_ptr<known_function> kf);
const known_function *get_by_identifier (tree identifier);
const known_function *get_by_fndecl (tree fndecl);
diff --git a/gcc/testsuite/gcc.dg/plugin/analyzer_kernel_plugin.c b/gcc/testsuite/gcc.dg/plugin/analyzer_kernel_plugin.c
index dfa30c8..92b4dfb 100644
--- a/gcc/testsuite/gcc.dg/plugin/analyzer_kernel_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/analyzer_kernel_plugin.c
@@ -210,10 +210,11 @@ kernel_analyzer_init_cb (void *gcc_data, void */*user_data*/)
LOG_SCOPE (iface->get_logger ());
if (0)
inform (input_location, "got here: kernel_analyzer_init_cb");
- iface->register_known_function ("copy_from_user",
- new known_function_copy_from_user ());
+ iface->register_known_function
+ ("copy_from_user",
+ make_unique<known_function_copy_from_user> ());
iface->register_known_function ("copy_to_user",
- new known_function_copy_to_user ());
+ make_unique<known_function_copy_to_user> ());
}
} // namespace ana
diff --git a/gcc/testsuite/gcc.dg/plugin/analyzer_known_fns_plugin.c b/gcc/testsuite/gcc.dg/plugin/analyzer_known_fns_plugin.c
index 5c1f398..e9f607f 100644
--- a/gcc/testsuite/gcc.dg/plugin/analyzer_known_fns_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/analyzer_known_fns_plugin.c
@@ -175,9 +175,10 @@ known_fn_analyzer_init_cb (void *gcc_data, void */*user_data*/)
if (0)
inform (input_location, "got here: known_fn_analyzer_init_cb");
iface->register_known_function ("returns_42",
- new known_function_returns_42 ());
- iface->register_known_function ("attempt_to_copy",
- new known_function_attempt_to_copy ());
+ make_unique<known_function_returns_42> ());
+ iface->register_known_function
+ ("attempt_to_copy",
+ make_unique<known_function_attempt_to_copy> ());
}
} // namespace ana