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>
This commit is contained in:
Lancelot Six
2023-10-13 09:27:48 +00:00
parent 6b62451ad0
commit 6b09f1342c
147 changed files with 417 additions and 416 deletions

View File

@@ -1045,7 +1045,7 @@ has_static_range (const struct range_bounds *bounds)
/* See gdbtypes.h. */
gdb::optional<LONGEST>
std::optional<LONGEST>
get_discrete_low_bound (struct type *type)
{
type = check_typedef (type);
@@ -1061,7 +1061,7 @@ get_discrete_low_bound (struct type *type)
if (type->target_type ()->code () == TYPE_CODE_ENUM)
{
gdb::optional<LONGEST> low_pos
std::optional<LONGEST> low_pos
= discrete_position (type->target_type (), low);
if (low_pos.has_value ())
@@ -1112,7 +1112,7 @@ get_discrete_low_bound (struct type *type)
/* See gdbtypes.h. */
gdb::optional<LONGEST>
std::optional<LONGEST>
get_discrete_high_bound (struct type *type)
{
type = check_typedef (type);
@@ -1128,7 +1128,7 @@ get_discrete_high_bound (struct type *type)
if (type->target_type ()->code () == TYPE_CODE_ENUM)
{
gdb::optional<LONGEST> high_pos
std::optional<LONGEST> high_pos
= discrete_position (type->target_type (), high);
if (high_pos.has_value ())
@@ -1191,11 +1191,11 @@ get_discrete_high_bound (struct type *type)
bool
get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
{
gdb::optional<LONGEST> low = get_discrete_low_bound (type);
std::optional<LONGEST> low = get_discrete_low_bound (type);
if (!low.has_value ())
return false;
gdb::optional<LONGEST> high = get_discrete_high_bound (type);
std::optional<LONGEST> high = get_discrete_high_bound (type);
if (!high.has_value ())
return false;
@@ -1243,7 +1243,7 @@ get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound)
in which case the value of POS is unmodified.
*/
gdb::optional<LONGEST>
std::optional<LONGEST>
discrete_position (struct type *type, LONGEST val)
{
if (type->code () == TYPE_CODE_RANGE)
@@ -2534,7 +2534,7 @@ compute_variant_fields_inner (struct type *type,
std::vector<bool> &flags)
{
/* Evaluate the discriminant. */
gdb::optional<ULONGEST> discr_value;
std::optional<ULONGEST> discr_value;
if (part.discriminant_index != -1)
{
int idx = part.discriminant_index;
@@ -2757,7 +2757,7 @@ resolve_dynamic_type_internal (struct type *type,
if (!is_dynamic_type_internal (real_type, top_level))
return type;
gdb::optional<CORE_ADDR> type_length;
std::optional<CORE_ADDR> type_length;
prop = TYPE_DYNAMIC_LENGTH (type);
if (prop != NULL
&& dwarf2_evaluate_property (prop, frame, addr_stack, &value))