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 /gdb/cli | |
parent | 6b62451ad08056f0ba02e192ec34ef67c4294ef4 (diff) | |
download | binutils-6b09f1342cf2d8e2b13a0d634acc3bcf2852a73b.zip binutils-6b09f1342cf2d8e2b13a0d634acc3bcf2852a73b.tar.gz binutils-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 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-cmds.c | 6 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.h | 4 | ||||
-rw-r--r-- | gdb/cli/cli-decode.c | 4 | ||||
-rw-r--r-- | gdb/cli/cli-decode.h | 2 | ||||
-rw-r--r-- | gdb/cli/cli-option.c | 14 | ||||
-rw-r--r-- | gdb/cli/cli-option.h | 2 |
6 files changed, 16 insertions, 16 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index fd93e5b..cb9ff55 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -655,12 +655,12 @@ show_script_ext_mode (struct ui_file *file, int from_tty, If SEARCH_PATH is non-zero, and the file isn't found in cwd, search for it in the source search path. */ -gdb::optional<open_script> +std::optional<open_script> find_and_open_script (const char *script_file, int search_path) { int fd; openp_flags search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH; - gdb::optional<open_script> opened; + std::optional<open_script> opened; gdb::unique_xmalloc_ptr<char> file (tilde_expand (script_file)); @@ -742,7 +742,7 @@ source_script_with_search (const char *file, int from_tty, int search_path) if (file == NULL || *file == 0) error (_("source command requires file name of file to source.")); - gdb::optional<open_script> opened = find_and_open_script (file, search_path); + std::optional<open_script> opened = find_and_open_script (file, search_path); if (!opened) { /* The script wasn't found, or was otherwise inaccessible. diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h index 4295744..a2579dc 100644 --- a/gdb/cli/cli-cmds.h +++ b/gdb/cli/cli-cmds.h @@ -18,7 +18,7 @@ #define CLI_CLI_CMDS_H #include "gdbsupport/filestuff.h" -#include "gdbsupport/gdb_optional.h" +#include <optional> #include "completer.h" /* Chain containing all defined commands. */ @@ -179,7 +179,7 @@ struct open_script } }; -extern gdb::optional<open_script> +extern std::optional<open_script> find_and_open_script (const char *file, int search_path); /* Command tracing state. */ diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 0bbe96b..940cd6a 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -24,7 +24,7 @@ #include "cli/cli-cmds.h" #include "cli/cli-decode.h" #include "cli/cli-style.h" -#include "gdbsupport/gdb_optional.h" +#include <optional> /* Prototypes for local functions. */ @@ -2727,7 +2727,7 @@ cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty) { if (!cmd->is_command_class_help ()) { - gdb::optional<scoped_restore_tmpl<bool>> restore_suppress; + std::optional<scoped_restore_tmpl<bool>> restore_suppress; if (cmd->suppress_notification != NULL) restore_suppress.emplace (cmd->suppress_notification, true); diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index 8fe9325..14d9c29 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -233,7 +233,7 @@ struct cmd_list_element void (*destroyer) (struct cmd_list_element *self, void *context) = nullptr; /* Setting affected by "set" and "show". Not used if type is not_set_cmd. */ - gdb::optional<setting> var; + std::optional<setting> var; /* Pointer to NULL terminated list of enumerated values (like argv). */ diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c index 9b303b1..d2d489b 100644 --- a/gdb/cli/cli-option.c +++ b/gdb/cli/cli-option.c @@ -58,11 +58,11 @@ struct option_def_and_value void *ctx; /* The option's value, if any. */ - gdb::optional<option_value> value; + std::optional<option_value> value; /* Constructor. */ option_def_and_value (const option_def &option_, void *ctx_, - gdb::optional<option_value> &&value_ = {}) + std::optional<option_value> &&value_ = {}) : option (option_), ctx (ctx_), value (std::move (value_)) @@ -99,7 +99,7 @@ private: allocated on the heap, so we must clear the pointer in the source, to avoid a double free. */ static void clear_value (const option_def &option, - gdb::optional<option_value> &value) + std::optional<option_value> &value) { if (value.has_value ()) { @@ -109,7 +109,7 @@ private: } }; -static void save_option_value_in_ctx (gdb::optional<option_def_and_value> &ov); +static void save_option_value_in_ctx (std::optional<option_def_and_value> &ov); /* Info passed around when handling completion. */ struct parse_option_completion_info @@ -177,7 +177,7 @@ complete_on_all_options (completion_tracker &tracker, /* Parse ARGS, guided by OPTIONS_GROUP. HAVE_DELIMITER is true if the whole ARGS line included the "--" options-terminator delimiter. */ -static gdb::optional<option_def_and_value> +static std::optional<option_def_and_value> parse_option (gdb::array_view<const option_def_group> options_group, process_options_mode mode, bool have_delimiter, @@ -496,7 +496,7 @@ complete_options (completion_tracker &tracker, } else if (**args == '-') { - gdb::optional<option_def_and_value> ov + std::optional<option_def_and_value> ov = parse_option (options_group, mode, have_delimiter, args, &completion_info); if (!ov && !tracker.have_completions ()) @@ -589,7 +589,7 @@ complete_options (completion_tracker &tracker, /* Save the parsed value in the option's context. */ static void -save_option_value_in_ctx (gdb::optional<option_def_and_value> &ov) +save_option_value_in_ctx (std::optional<option_def_and_value> &ov) { switch (ov->option.type) { diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h index 7b015b8..4c62227 100644 --- a/gdb/cli/cli-option.h +++ b/gdb/cli/cli-option.h @@ -20,7 +20,7 @@ #ifndef CLI_OPTION_H #define CLI_OPTION_H 1 -#include "gdbsupport/gdb_optional.h" +#include <optional> #include "gdbsupport/array-view.h" #include "completer.h" #include <string> |