Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Add DISABLE_COPY_AND_ASSIGN
Date: Tue, 18 Jul 2017 14:22:00 -0000	[thread overview]
Message-ID: <179e2d35-d903-1d6d-256a-063a35d677d2@redhat.com> (raw)
In-Reply-To: <1500385686-19857-1-git-send-email-yao.qi@linaro.org>

On 07/18/2017 02:48 PM, Yao Qi wrote:
> We have many classes that copy cotr and assignment operator are deleted,
> so this patch adds a macro to do this, and replace these existing
> mechanical code with macro DISABLE_COPY_AND_ASSIGN.

Yes, please.  I've been meaning to add something like this for a while.

IMO, this could go in include/ansidecl.h, with a fallback version for
#if __cplusplus < C++11 that declares the methods without =delete (you
get a link error instead).

>  /* Pull in gdb::unique_xmalloc_ptr.  */
>  #include "common/gdb_unique_ptr.h"
>  
> +#define DISABLE_COPY_AND_ASSIGN(TYPE)		\
> +  TYPE (const TYPE&) = delete;			\
> +  void operator= (const TYPE &) = delete;
> +

Should this have an intro comment?

> --- a/gdb/common/refcounted-object.h
> +++ b/gdb/common/refcounted-object.h
> @@ -19,6 +19,8 @@
>  #ifndef REFCOUNTED_OBJECT_H
>  #define REFCOUNTED_OBJECT_H
>  
> +#include "common-defs.h"
> +

This should not be necessary (and is against the guidelines [1]),
since .c files must include defs.h/common-defs.h first thing.  Why did
you need it?

[1] https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Include_Files

Thanks,
Pedro Alves


  reply	other threads:[~2017-07-18 14:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18 13:48 Yao Qi
2017-07-18 14:22 ` Pedro Alves [this message]
2017-07-18 15:13   ` Yao Qi
2017-07-18 15:38     ` Pedro Alves
2017-09-09 18:45       ` Simon Marchi
2017-09-15 12:05         ` Yao Qi
2017-09-19  9:13 ` Yao Qi

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=179e2d35-d903-1d6d-256a-063a35d677d2@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    /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