
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.
54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
/* Base class of intrusively reference-counted objects.
|
|
Copyright (C) 2017 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef REFCOUNTED_OBJECT_H
|
|
#define REFCOUNTED_OBJECT_H
|
|
|
|
/* Base class of intrusively reference-countable objects.
|
|
Incrementing and decrementing the reference count is an external
|
|
responsibility. */
|
|
|
|
class refcounted_object
|
|
{
|
|
public:
|
|
refcounted_object () = default;
|
|
|
|
/* Increase the refcount. */
|
|
void incref ()
|
|
{
|
|
gdb_assert (m_refcount >= 0);
|
|
m_refcount++;
|
|
}
|
|
|
|
/* Decrease the refcount. */
|
|
void decref ()
|
|
{
|
|
m_refcount--;
|
|
gdb_assert (m_refcount >= 0);
|
|
}
|
|
|
|
int refcount () const { return m_refcount; }
|
|
|
|
private:
|
|
DISABLE_COPY_AND_ASSIGN (refcounted_object);
|
|
|
|
/* The reference count. */
|
|
int m_refcount = 0;
|
|
};
|
|
|
|
#endif /* REFCOUNTED_OBJECT_H */
|