public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 2/2] Remove xmethod_worker::clone
Date: Mon, 27 Nov 2017 00:48:00 -0000	[thread overview]
Message-ID: <20171127004819.18941-2-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20171127004819.18941-1-simon.marchi@polymtl.ca>

I think that the clone method of xmethod_worker can be removed.  It is
only used in find_overload_match, to clone an xmethod we want to
keep.  Instead, we can just std::move it out of the vector and into
value_from_xmethod.  value_from_xmethod creates a value that will own
the xmethod_worker from that point.  Other xmethod_workers left in the
vector will get destroyed when the vector gets destroyed, but the chosen
one will keep living inside the value struct.

gdb/ChangeLog:

	* extension.h (struct xmethod_worker) <clone>: Remove.
	* python/py-xmethods.c (struct python_xmethod_worker) <clone>:
	Remove.
	(python_xmethod_worker::clone): Remove.
	* valops.c (find_overload_match): Use std::move instead of
	clone.
---
 gdb/extension.h          |  7 -------
 gdb/python/py-xmethods.c | 17 -----------------
 gdb/valops.c             |  2 +-
 3 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/gdb/extension.h b/gdb/extension.h
index e1f26acdc1..ebdcb34aba 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -182,13 +182,6 @@ struct xmethod_worker
 
   virtual value *invoke (value *obj, value **args, int nargs) = 0;
 
-  /* Clone this worker, returns a new but identical worker.
-     The function get_matching_xmethod_workers returns a vector of matching
-     workers.  If a particular worker is selected by GDB to invoke a method,
-     then this function can help in cloning the selected worker.  */
-
-  virtual std::unique_ptr<xmethod_worker> clone () = 0;
-
   /* Return the arg types of the xmethod encapsulated in this worker.
      An array of arg types is returned.  The length of the array is returned in
      NARGS.  The type of the 'this' object is returned as the first element of
diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
index 6d839c5dac..31d0bda647 100644
--- a/gdb/python/py-xmethods.c
+++ b/gdb/python/py-xmethods.c
@@ -48,10 +48,6 @@ struct python_xmethod_worker : xmethod_worker
 
   value *invoke (value *obj, value **args, int nargs) override;
 
-  /* Implementation of xmethod_worker::clone for Python.  */
-
-  xmethod_worker_up clone () override;
-
   /* Implementation of xmethod_worker::do_get_arg_types for Python.  */
 
   ext_lang_rc do_get_arg_types (int *nargs, type ***arg_types) override;
@@ -80,19 +76,6 @@ python_xmethod_worker::~python_xmethod_worker ()
   Py_DECREF (m_this_type);
 }
 
-/* See declaration.  */
-
-xmethod_worker_up
-python_xmethod_worker::clone ()
-{
-  /* We don't do much here, but we still need the GIL.  */
-  gdbpy_enter enter_py (get_current_arch (), current_language);
-
-  xmethod_worker *worker = new python_xmethod_worker (m_py_worker, m_this_type);
-
-  return xmethod_worker_up (worker);
-}
-
 /* Invoke the "match" method of the MATCHER and return a new reference
    to the result.  Returns NULL on error.  */
 
diff --git a/gdb/valops.c b/gdb/valops.c
index f9f9439b0c..32dc083752 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -2778,7 +2778,7 @@ find_overload_match (struct value **args, int nargs,
 	}
       else
 	*valp = value_from_xmethod
-	  (xm_worker_vec[ext_method_oload_champ]->clone ());
+	  (std::move (xm_worker_vec[ext_method_oload_champ]));
     }
   else
     *symp = oload_syms[func_oload_champ];
-- 
2.15.0

  reply	other threads:[~2017-11-27  0:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-27  0:48 [PATCH 1/2] C++ify xmethod_worker, get rid of VEC(xmethod_worker_ptr) Simon Marchi
2017-11-27  0:48 ` Simon Marchi [this message]
2017-11-27 13:54 Simon Marchi
2017-11-27 13:54 ` [PATCH 2/2] Remove xmethod_worker::clone Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171127004819.18941-2-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).