diff options
author | Lancelot Six <lancelot.six@amd.com> | 2023-10-13 09:27:48 +0000 |
---|---|---|
committer | Lancelot Six <lancelot.six@amd.com> | 2023-11-21 11:52:35 +0000 |
commit | 6b09f1342cf2d8e2b13a0d634acc3bcf2852a73b (patch) | |
tree | 07259601270022a6cbeb89826560262f015e1589 /gdbsupport | |
parent | 6b62451ad08056f0ba02e192ec34ef67c4294ef4 (diff) | |
download | fsf-binutils-gdb-6b09f1342cf2d8e2b13a0d634acc3bcf2852a73b.zip fsf-binutils-gdb-6b09f1342cf2d8e2b13a0d634acc3bcf2852a73b.tar.gz fsf-binutils-gdb-6b09f1342cf2d8e2b13a0d634acc3bcf2852a73b.tar.bz2 |
gdb: Replace gdb::optional with std::optional
Since GDB now requires C++17, we don't need the internally maintained
gdb::optional implementation. This patch does the following replacing:
- gdb::optional -> std::optional
- gdb::in_place -> std::in_place
- #include "gdbsupport/gdb_optional.h" -> #include <optional>
This change has mostly been done automatically. One exception is
gdbsupport/thread-pool.* which did not use the gdb:: prefix as it
already lives in the gdb namespace.
Change-Id: I19a92fa03e89637bab136c72e34fd351524f65e9
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
Diffstat (limited to 'gdbsupport')
-rw-r--r-- | gdbsupport/common-debug.h | 4 | ||||
-rw-r--r-- | gdbsupport/event-loop.cc | 6 | ||||
-rw-r--r-- | gdbsupport/filestuff.cc | 2 | ||||
-rw-r--r-- | gdbsupport/filestuff.h | 2 | ||||
-rw-r--r-- | gdbsupport/forward-scope-exit.h | 6 | ||||
-rw-r--r-- | gdbsupport/range-chain.h | 2 | ||||
-rw-r--r-- | gdbsupport/scoped_ignore_sigttou.h | 2 | ||||
-rw-r--r-- | gdbsupport/thread-pool.cc | 2 | ||||
-rw-r--r-- | gdbsupport/thread-pool.h | 4 |
9 files changed, 15 insertions, 15 deletions
diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h index 33b15a0..8908669 100644 --- a/gdbsupport/common-debug.h +++ b/gdbsupport/common-debug.h @@ -20,7 +20,7 @@ #ifndef COMMON_COMMON_DEBUG_H #define COMMON_COMMON_DEBUG_H -#include "gdbsupport/gdb_optional.h" +#include <optional> #include "gdbsupport/preprocessor.h" #include <stdarg.h> @@ -200,7 +200,7 @@ private: const char *m_end_prefix; /* The result of formatting the format string in the constructor. */ - gdb::optional<std::string> m_msg; + std::optional<std::string> m_msg; /* True is a non-nullptr format was passed to the constructor. */ bool m_with_format; diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc index 52e7fd2..031c2ff 100644 --- a/gdbsupport/event-loop.cc +++ b/gdbsupport/event-loop.cc @@ -33,7 +33,7 @@ #include <sys/types.h> #include "gdbsupport/gdb_sys_time.h" #include "gdbsupport/gdb_select.h" -#include "gdbsupport/gdb_optional.h" +#include <optional> #include "gdbsupport/scope-exit.h" /* See event-loop.h. */ @@ -246,7 +246,7 @@ gdb_do_one_event (int mstimeout) When the timeout is reached, events are not monitored again: they already have been checked in the loop above. */ - gdb::optional<int> timer_id; + std::optional<int> timer_id; SCOPE_EXIT { @@ -258,7 +258,7 @@ gdb_do_one_event (int mstimeout) timer_id = create_timer (mstimeout, [] (gdb_client_data arg) { - ((gdb::optional<int> *) arg)->reset (); + ((std::optional<int> *) arg)->reset (); }, &timer_id); return gdb_wait_for_event (1); diff --git a/gdbsupport/filestuff.cc b/gdbsupport/filestuff.cc index 9e61fea..334bae8 100644 --- a/gdbsupport/filestuff.cc +++ b/gdbsupport/filestuff.cc @@ -504,7 +504,7 @@ mkdir_recursive (const char *dir) /* See gdbsupport/filestuff.h. */ -gdb::optional<std::string> +std::optional<std::string> read_text_file_to_string (const char *path) { gdb_file_up file = gdb_fopen_cloexec (path, "r"); diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h index 48bef51..206b51e 100644 --- a/gdbsupport/filestuff.h +++ b/gdbsupport/filestuff.h @@ -131,6 +131,6 @@ extern bool mkdir_recursive (const char *dir); /* Read the entire content of file PATH into an std::string. */ -extern gdb::optional<std::string> read_text_file_to_string (const char *path); +extern std::optional<std::string> read_text_file_to_string (const char *path); #endif /* COMMON_FILESTUFF_H */ diff --git a/gdbsupport/forward-scope-exit.h b/gdbsupport/forward-scope-exit.h index bf591dd..0552e11 100644 --- a/gdbsupport/forward-scope-exit.h +++ b/gdbsupport/forward-scope-exit.h @@ -52,9 +52,9 @@ obj.release (); // Optional cancel if needed. forward_scope_exit is also handy when you would need to wrap a - scope_exit in a gdb::optional: + scope_exit in a std::optional: - gdb::optional<longjmp_breakpoint_cleanup> cleanup; + std::optional<longjmp_breakpoint_cleanup> cleanup; if (some condition) cleanup.emplace (thread); ... @@ -62,7 +62,7 @@ cleanup->release (); since with scope exit, you would have to know the scope_exit's - callable template type when you create the gdb::optional: + callable template type when you create the std::optional: gdb:optional<scope_exit<what goes here?>> diff --git a/gdbsupport/range-chain.h b/gdbsupport/range-chain.h index 01d6cf0..3cebce0 100644 --- a/gdbsupport/range-chain.h +++ b/gdbsupport/range-chain.h @@ -90,7 +90,7 @@ struct range_chain /* The current iterator into one of the vector ranges. If no value then this (outer) iterator is at the end of the overall range. */ - gdb::optional<typename Range::iterator> m_current; + std::optional<typename Range::iterator> m_current; /* Vector of ranges. */ const std::vector<Range> &m_ranges; }; diff --git a/gdbsupport/scoped_ignore_sigttou.h b/gdbsupport/scoped_ignore_sigttou.h index a3f8361..558fb7f 100644 --- a/gdbsupport/scoped_ignore_sigttou.h +++ b/gdbsupport/scoped_ignore_sigttou.h @@ -26,7 +26,7 @@ #ifdef SIGTTOU /* Simple wrapper that allows lazy initialization / destruction of T. - Slightly more efficient than gdb::optional, because it doesn't + Slightly more efficient than std::optional, because it doesn't carry storage to track whether the object has been initialized. */ template<typename T> class lazy_init diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc index 1c871ed..bbe043d 100644 --- a/gdbsupport/thread-pool.cc +++ b/gdbsupport/thread-pool.cc @@ -225,7 +225,7 @@ thread_pool::thread_function () while (true) { - optional<task_t> t; + std::optional<task_t> t; { /* We want to hold the lock while examining the task list, but diff --git a/gdbsupport/thread-pool.h b/gdbsupport/thread-pool.h index cb8696e..d5e1dc7 100644 --- a/gdbsupport/thread-pool.h +++ b/gdbsupport/thread-pool.h @@ -30,7 +30,7 @@ #include <condition_variable> #include <future> #endif -#include "gdbsupport/gdb_optional.h" +#include <optional> namespace gdb { @@ -198,7 +198,7 @@ private: to represent a task. If the optional is empty, then this means that the receiving thread should terminate. If the optional is non-empty, then it is an actual task to evaluate. */ - std::queue<optional<task_t>> m_tasks; + std::queue<std::optional<task_t>> m_tasks; /* A condition variable and mutex that are used for communication between the main thread and the worker threads. */ |