[binutils-gdb] gdb: add noexcept to relevant methods of class ref_ptr
Matthieu Longo
mlongo@sourceware.org
Mon Jan 26 14:29:12 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9fbbc2ed43ef26834ca46aededff3c569c2431c6
commit 9fbbc2ed43ef26834ca46aededff3c569c2431c6
Author: Matthieu Longo <matthieu.longo@arm.com>
Date: Thu Oct 23 17:20:50 2025 +0100
gdb: add noexcept to relevant methods of class ref_ptr
This patch aims at improving code readability and maintainability
by adding the 'noexcept' attribute to some constructors and
methods of class 'ref_ptr' to make clear that no exception is
supposed to be raised from them.
As an additional benefit, the compiler doesn't need to generate
the stack unwinding code for those constructors and methods.
Approved-By: Tom Tromey <tom@tromey.com>
Diff:
---
gdbsupport/gdb_ref_ptr.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gdbsupport/gdb_ref_ptr.h b/gdbsupport/gdb_ref_ptr.h
index b6d5346373f..3d01bf4441b 100644
--- a/gdbsupport/gdb_ref_ptr.h
+++ b/gdbsupport/gdb_ref_ptr.h
@@ -51,20 +51,20 @@ class ref_ptr
public:
/* Create a new NULL instance. */
- ref_ptr ()
+ ref_ptr () noexcept
: m_obj (NULL)
{
}
/* Create a new NULL instance. Note that this is not explicit. */
- ref_ptr (const std::nullptr_t)
+ ref_ptr (const std::nullptr_t) noexcept
: m_obj (NULL)
{
}
/* Create a new instance. OBJ is a reference, management of which
is now transferred to this class. */
- explicit ref_ptr (T *obj)
+ explicit ref_ptr (T *obj) noexcept
: m_obj (obj)
{
}
@@ -127,7 +127,7 @@ class ref_ptr
/* Return this instance's referent without changing the state of
this class. */
- T *get () const
+ T *get () const noexcept
{
return m_obj;
}
@@ -135,7 +135,7 @@ class ref_ptr
/* Return this instance's referent, and stop managing this
reference. The caller is now responsible for the ownership of
the reference. */
- ATTRIBUTE_UNUSED_RESULT T *release ()
+ ATTRIBUTE_UNUSED_RESULT T *release () noexcept
{
T *result = m_obj;
@@ -144,7 +144,7 @@ class ref_ptr
}
/* Let users refer to members of the underlying pointer. */
- T *operator-> () const
+ T *operator-> () const noexcept
{
return m_obj;
}
More information about the Gdb-cvs
mailing list