Do not define basic_string_view::to_string
authorTom Tromey <tromey@adacore.com>
Tue, 30 Jun 2020 13:53:03 +0000 (07:53 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 30 Jun 2020 13:53:03 +0000 (07:53 -0600)
commit5ac588997c3c2d032d5d5145d9245eb37354c23b
tree984da0cf53258094e83d06c9bac4b85ef6d798dc
parent5568cc9ee83148042b853131a33007a9f36ab1eb
Do not define basic_string_view::to_string

gdb's copy of basic_string_view includes a to_string method.  However,
according to cppreference, this is not a method on the real
std::basic_string_view:

https://en.cppreference.com/w/cpp/string/basic_string_view

This difference matters because gdb_string_view.h will use the
standard implementation when built with a C++17 or later.  This caused
PR build/26183.

This patch fixes the problem by changing the method to be a standalone
helper function, and then rewriting the uses.  Tested by rebuilding
with a version of GCC that defaults to C++17.

(Note that the build still is not clean; and also I noticed that the
libstdc++ string_view forbids the use of nullptr ... I wonder if gdb
violates that.)

gdb/ChangeLog
2020-06-30  Tom Tromey  <tromey@adacore.com>

PR build/26183:
* ada-lang.c (ada_lookup_name_info::ada_lookup_name_info): Use
gdb::to_string.

gdbsupport/ChangeLog
2020-06-30  Tom Tromey  <tromey@adacore.com>

PR build/26183:
* gdb_string_view.h (basic_string_view::to_string): Remove.
(gdb::to_string): New function.
gdb/ChangeLog
gdb/ada-lang.c
gdbsupport/ChangeLog
gdbsupport/gdb_string_view.h