From 0fa7617d84da8b809b14e1e2ee67474526c62021 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 20 Apr 2020 11:45:06 -0600 Subject: Mark move constructors as "noexcept" I recently learned that move constructors generally should be marked "noexcept". This ensures that standard containers will move objects when possible, rather than copy them. This patch fixes the cases I could find. Note that implicitly-defined or defaulted move constructors will automatically do what you'd expect; that is, they are noexcept if all the members have noexcept move constructors. While doing this, I noticed a couple of odd cases where the move constructor seemed to assume that the object being constructed could have state requiring destruction. I've fixed these as well. See completion_result and scoped_mmap. gdb/ChangeLog 2020-04-20 Tom Tromey * python/python.c (struct gdbpy_event): Mark move constructor as noexcept. * python/py-tui.c (class gdbpy_tui_window_maker): Mark move constructor as noexcept. * completer.h (struct completion_result): Mark move constructor as noexcept. * completer.c (completion_result::completion_result): Use initialization style. Don't call reset_match_list. gdbsupport/ChangeLog 2020-04-20 Tom Tromey * scoped_mmap.h (scoped_mmap): Mark move constructor as noexcept. Use initialization style. Don't call destroy. * scoped_fd.h (class scoped_fd): Mark move constructor as noexcept. * gdb_ref_ptr.h (class ref_ptr): Mark move constructor as noexcept. --- gdb/python/py-tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gdb/python/py-tui.c') diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c index de7c396..ca88f85 100644 --- a/gdb/python/py-tui.c +++ b/gdb/python/py-tui.c @@ -233,7 +233,7 @@ public: ~gdbpy_tui_window_maker (); - gdbpy_tui_window_maker (gdbpy_tui_window_maker &&other) + gdbpy_tui_window_maker (gdbpy_tui_window_maker &&other) noexcept : m_constr (std::move (other.m_constr)) { } -- cgit v1.1