Use DISABLE_COPY_AND_ASSIGN

We have many classes that copy cotr and assignment operator are deleted,
so this patch replaces these existing mechanical code with macro
DISABLE_COPY_AND_ASSIGN.

gdb:

2017-09-19  Yao Qi  <yao.qi@linaro.org>

	* annotate.h (struct annotate_arg_emitter): Use
	DISABLE_COPY_AND_ASSIGN.
	* common/refcounted-object.h (refcounted_object): Likewise.
	* completer.h (struct completion_result): Likewise.
	* dwarf2read.c (struct dwarf2_per_objfile): Likewise.
	* filename-seen-cache.h (filename_seen_cache): Likewise.
	* gdbcore.h (thread_section_name): Likewise.
	* gdb_regex.h (compiled_regex): Likewise.
	* gdbthread.h (scoped_restore_current_thread): Likewise.
	* inferior.h (scoped_restore_current_inferior): Likewise.
	* jit.c (jit_reader): Likewise.
	* linespec.h (struct linespec_result): Likewise.
	* mi/mi-parse.h (struct mi_parse): Likewise.
	* nat/fork-inferior.c (execv_argv): Likewise.
	* progspace.h (scoped_restore_current_program_space): Likewise.
	* python/python-internal.h (class gdbpy_enter): Likewise.
	* regcache.h (regcache): Likewise.
	* target-descriptions.c (struct tdesc_reg): Likewise.
	(struct tdesc_type): Likewise.
	(struct tdesc_feature): Likewise.
	* ui-out.h (ui_out_emit_type): Likewise.
This commit is contained in:
Yao Qi 2017-09-19 10:10:03 +01:00
parent 25516cc573
commit d654162044
19 changed files with 46 additions and 63 deletions

View file

@ -1,3 +1,27 @@
2017-09-19 Yao Qi <yao.qi@linaro.org>
* annotate.h (struct annotate_arg_emitter): Use
DISABLE_COPY_AND_ASSIGN.
* common/refcounted-object.h (refcounted_object): Likewise.
* completer.h (struct completion_result): Likewise.
* dwarf2read.c (struct dwarf2_per_objfile): Likewise.
* filename-seen-cache.h (filename_seen_cache): Likewise.
* gdbcore.h (thread_section_name): Likewise.
* gdb_regex.h (compiled_regex): Likewise.
* gdbthread.h (scoped_restore_current_thread): Likewise.
* inferior.h (scoped_restore_current_inferior): Likewise.
* jit.c (jit_reader): Likewise.
* linespec.h (struct linespec_result): Likewise.
* mi/mi-parse.h (struct mi_parse): Likewise.
* nat/fork-inferior.c (execv_argv): Likewise.
* progspace.h (scoped_restore_current_program_space): Likewise.
* python/python-internal.h (class gdbpy_enter): Likewise.
* regcache.h (regcache): Likewise.
* target-descriptions.c (struct tdesc_reg): Likewise.
(struct tdesc_type): Likewise.
(struct tdesc_feature): Likewise.
* ui-out.h (ui_out_emit_type): Likewise.
2017-09-18 Simon Marchi <simon.marchi@ericsson.com> 2017-09-18 Simon Marchi <simon.marchi@ericsson.com>
* dwarf2expr.c (dwarf_expr_context::execute_stack_op): Remove * dwarf2expr.c (dwarf_expr_context::execute_stack_op): Remove

View file

@ -81,8 +81,7 @@ struct annotate_arg_emitter
annotate_arg_emitter () { annotate_arg_begin (); } annotate_arg_emitter () { annotate_arg_begin (); }
~annotate_arg_emitter () { annotate_arg_end (); } ~annotate_arg_emitter () { annotate_arg_end (); }
annotate_arg_emitter (const annotate_arg_emitter &) = delete; DISABLE_COPY_AND_ASSIGN (annotate_arg_emitter);
annotate_arg_emitter &operator= (const annotate_arg_emitter &) = delete;
}; };
extern void annotate_source (char *, int, int, int, extern void annotate_source (char *, int, int, int,

View file

@ -45,9 +45,7 @@ public:
int refcount () const { return m_refcount; } int refcount () const { return m_refcount; }
private: private:
/* Disable copy. */ DISABLE_COPY_AND_ASSIGN (refcounted_object);
refcounted_object (const refcounted_object &) = delete;
refcounted_object &operator=(const refcounted_object &) = delete;
/* The reference count. */ /* The reference count. */
int m_refcount = 0; int m_refcount = 0;

View file

@ -85,9 +85,7 @@ struct completion_result
/* Destroy a result. */ /* Destroy a result. */
~completion_result (); ~completion_result ();
/* Disable copying, since we don't need it. */ DISABLE_COPY_AND_ASSIGN (completion_result);
completion_result (const completion_result &rhs) = delete;
void operator= (const completion_result &rhs) = delete;
/* Move a result. */ /* Move a result. */
completion_result (completion_result &&rhs); completion_result (completion_result &&rhs);
@ -146,9 +144,7 @@ public:
completion_tracker (); completion_tracker ();
~completion_tracker (); ~completion_tracker ();
/* Disable copy. */ DISABLE_COPY_AND_ASSIGN (completion_tracker);
completion_tracker (const completion_tracker &rhs) = delete;
void operator= (const completion_tracker &rhs) = delete;
/* Add the completion NAME to the list of generated completions if /* Add the completion NAME to the list of generated completions if
it is not there already. If too many completions were already it is not there already. If too many completions were already

View file

@ -232,9 +232,7 @@ struct dwarf2_per_objfile
~dwarf2_per_objfile (); ~dwarf2_per_objfile ();
/* Disable copy. */ DISABLE_COPY_AND_ASSIGN (dwarf2_per_objfile);
dwarf2_per_objfile (const dwarf2_per_objfile &) = delete;
void operator= (const dwarf2_per_objfile &) = delete;
/* Free all cached compilation units. */ /* Free all cached compilation units. */
void free_cached_comp_units (); void free_cached_comp_units ();

View file

@ -28,9 +28,7 @@ public:
filename_seen_cache (); filename_seen_cache ();
~filename_seen_cache (); ~filename_seen_cache ();
/* Disable copy. */ DISABLE_COPY_AND_ASSIGN (filename_seen_cache);
filename_seen_cache (const filename_seen_cache &) = delete;
void operator= (const filename_seen_cache &) = delete;
/* Empty the cache, but do not delete it. */ /* Empty the cache, but do not delete it. */
void clear (); void clear ();

View file

@ -43,9 +43,7 @@ public:
~compiled_regex (); ~compiled_regex ();
/* Disable copy. */ DISABLE_COPY_AND_ASSIGN (compiled_regex);
compiled_regex (const compiled_regex&) = delete;
void operator= (const compiled_regex&) = delete;
/* Wrapper around ::regexec. */ /* Wrapper around ::regexec. */
int exec (const char *string, int exec (const char *string,

View file

@ -258,9 +258,7 @@ public:
const char *c_str () const const char *c_str () const
{ return m_section_name; } { return m_section_name; }
/* Disable copy. */ DISABLE_COPY_AND_ASSIGN (thread_section_name);
thread_section_name (const thread_section_name &) = delete;
void operator= (const thread_section_name &) = delete;
private: private:
/* Either a pointer into M_STORAGE, or a pointer to the name passed /* Either a pointer into M_STORAGE, or a pointer to the name passed

View file

@ -597,11 +597,7 @@ public:
scoped_restore_current_thread (); scoped_restore_current_thread ();
~scoped_restore_current_thread (); ~scoped_restore_current_thread ();
/* Disable copy. */ DISABLE_COPY_AND_ASSIGN (scoped_restore_current_thread);
scoped_restore_current_thread
(const scoped_restore_current_thread &) = delete;
void operator=
(const scoped_restore_current_thread &) = delete;
private: private:
thread_info *m_thread; thread_info *m_thread;

View file

@ -527,11 +527,7 @@ public:
~scoped_restore_current_inferior () ~scoped_restore_current_inferior ()
{ set_current_inferior (m_saved_inf); } { set_current_inferior (m_saved_inf); }
/* Disable copy. */ DISABLE_COPY_AND_ASSIGN (scoped_restore_current_inferior);
scoped_restore_current_inferior
(const scoped_restore_current_inferior &) = delete;
void operator=
(const scoped_restore_current_inferior &) = delete;
private: private:
inferior *m_saved_inf; inferior *m_saved_inf;

View file

@ -163,8 +163,7 @@ struct jit_reader
functions->destroy (functions); functions->destroy (functions);
} }
jit_reader (const jit_reader &) = delete; DISABLE_COPY_AND_ASSIGN (jit_reader);
jit_reader &operator= (const jit_reader &) = delete;
struct gdb_reader_funcs *functions; struct gdb_reader_funcs *functions;
gdb_dlhandle_up handle; gdb_dlhandle_up handle;

View file

@ -58,8 +58,7 @@ struct linespec_result
linespec_result () = default; linespec_result () = default;
~linespec_result (); ~linespec_result ();
linespec_result (const linespec_result &) = delete; DISABLE_COPY_AND_ASSIGN (linespec_result);
linespec_result &operator= (const linespec_result &) = delete;
/* If true, the linespec should be displayed to the user. This /* If true, the linespec should be displayed to the user. This
is used by "unusual" linespecs where the ordinary `info break' is used by "unusual" linespecs where the ordinary `info break'

View file

@ -44,8 +44,7 @@ struct mi_parse
mi_parse (); mi_parse ();
~mi_parse (); ~mi_parse ();
mi_parse (const mi_parse &) = delete; DISABLE_COPY_AND_ASSIGN (mi_parse);
mi_parse &operator= (const mi_parse &) = delete;
enum mi_command_type op; enum mi_command_type op;
char *command; char *command;

View file

@ -56,9 +56,7 @@ public:
} }
private: private:
/* Disable copying. */ DISABLE_COPY_AND_ASSIGN (execv_argv);
execv_argv (const execv_argv &) = delete;
void operator= (const execv_argv &) = delete;
/* Helper methods for constructing the argument vector. */ /* Helper methods for constructing the argument vector. */

View file

@ -273,11 +273,7 @@ public:
~scoped_restore_current_program_space () ~scoped_restore_current_program_space ()
{ set_current_program_space (m_saved_pspace); } { set_current_program_space (m_saved_pspace); }
/* Disable copy. */ DISABLE_COPY_AND_ASSIGN (scoped_restore_current_program_space);
scoped_restore_current_program_space
(const scoped_restore_current_program_space &) = delete;
void operator=
(const scoped_restore_current_program_space &) = delete;
private: private:
program_space *m_saved_pspace; program_space *m_saved_pspace;

View file

@ -624,8 +624,7 @@ class gdbpy_enter
~gdbpy_enter (); ~gdbpy_enter ();
gdbpy_enter (const gdbpy_enter &) = delete; DISABLE_COPY_AND_ASSIGN (gdbpy_enter);
gdbpy_enter &operator= (const gdbpy_enter &) = delete;
private: private:

View file

@ -255,8 +255,7 @@ public:
/* Create a readonly regcache from a non-readonly regcache. */ /* Create a readonly regcache from a non-readonly regcache. */
regcache (readonly_t, const regcache &src); regcache (readonly_t, const regcache &src);
regcache (const regcache &) = delete; DISABLE_COPY_AND_ASSIGN (regcache);
void operator= (const regcache &) = delete;
/* class regcache is only extended in unit test, so only mark it /* class regcache is only extended in unit test, so only mark it
virtual when selftest is enabled. */ virtual when selftest is enabled. */

View file

@ -93,9 +93,7 @@ typedef struct tdesc_reg : tdesc_element
xfree (group); xfree (group);
} }
/* Disable copying. */ DISABLE_COPY_AND_ASSIGN (tdesc_reg);
tdesc_reg (const tdesc_reg &) = delete;
tdesc_reg &operator= (const tdesc_reg &) = delete;
/* The name of this register. In standard features, it may be /* The name of this register. In standard features, it may be
recognized by the architecture support code, or it may be purely recognized by the architecture support code, or it may be purely
@ -229,9 +227,8 @@ typedef struct tdesc_type : tdesc_element
} }
xfree ((char *) name); xfree ((char *) name);
} }
/* Disable copying. */
tdesc_type (const tdesc_type &) = delete; DISABLE_COPY_AND_ASSIGN (tdesc_type);
tdesc_type &operator= (const tdesc_type &) = delete;
/* The name of this type. If this type is a built-in type, this is /* The name of this type. If this type is a built-in type, this is
a pointer to a constant string. Otherwise, it's a a pointer to a constant string. Otherwise, it's a
@ -302,9 +299,7 @@ typedef struct tdesc_feature : tdesc_element
xfree (name); xfree (name);
} }
/* Disable copying. */ DISABLE_COPY_AND_ASSIGN (tdesc_feature);
tdesc_feature (const tdesc_feature &) = delete;
tdesc_feature &operator= (const tdesc_feature &) = delete;
/* The name of this feature. It may be recognized by the architecture /* The name of this feature. It may be recognized by the architecture
support code. */ support code. */

View file

@ -204,9 +204,7 @@ public:
m_uiout->end (Type); m_uiout->end (Type);
} }
ui_out_emit_type (const ui_out_emit_type<Type> &) = delete; DISABLE_COPY_AND_ASSIGN (ui_out_emit_type<Type>);
ui_out_emit_type<Type> &operator= (const ui_out_emit_type<Type> &)
= delete;
private: private: