binutils-gdb/gdb/cli
Simon Marchi 8345c4a267 Add gdb::string_view
We had a few times the need for a data structure that does essentially
what C++17's std::string_view does, which is to give an std::string-like
interface (only the read-only operations) to an arbitrary character
buffer.

This patch adapts the files copied from libstdc++ by the previous patch
to integrate them with GDB.  Here's a summary of the changes:

  * Remove things related to wstring_view, u16string_view and
  u32string_view (I don't think we need them, but we can always add them
  later).

  * Remove usages of _GLIBCXX_BEGIN_NAMESPACE_VERSION and
  _GLIBCXX_END_NAMESPACE_VERSION.

  * Put the code in the gdb namespace.  I had to add a few "std::" in
  front of std type usages.

  * Change __throw_out_of_range_fmt() for error().

  * Make gdb::string_view an alias of std::string_view when building
  with >= c++17.

  * Remove a bunch of constexpr, because they are not valid in c++11
  (e.g. they are not a single return line).

  * Use std::common_type<_Tp>::type instead of std::common_type_t<_Tp>,
  because c++11 doesn't have the later.

  * Remove the #pragma GCC system_header, since that silences some
  warnings that we might want to have if we're doing something not
  correctly.

  * Remove operator ""sv.  It would need a lot of work to make all
  supported compilers happy, and we can easily live without it.

  * Remove operator<<.  It is implemented using __ostream_insert (a
  libstdc++ internal).  Bringing it in might be possible, but I don't
  think that would be worth the effort, since we don't really use
  streams at the moment.

  * Replace internal libstdc++ asserts ( __glibcxx_assert and
  __glibcxx_requires_string_len) with gdb_assert.

  * Remove hash helpers, because they use libstdc++ internal functions.
  If we need them we always import them later.

The string_view class in cli/cli-script.c is removed and its usage
replaced with the new gdb::string_view.

gdb/ChangeLog:

	* common/gdb_string_view.h: Remove libstdc++ implementation
	details, adjust to gdb reality.
	* common/gdb_string_view.tcc: Likewise.
	* cli/cli-script.c (struct string_view): Remove.
	(user_args) <m_args>: Change element type to gdb::string_view.
	(user_args::insert_args): Adjust.
2018-04-09 14:20:46 -04:00
..
cli-cmds.c Change openp et al to use a unique_xmalloc_ptr 2018-02-14 08:09:53 -07:00
cli-cmds.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
cli-decode.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
cli-decode.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
cli-dump.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
cli-interp.c Convert observers to C++ 2018-03-19 09:37:49 -06:00
cli-interp.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
cli-logging.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
cli-script.c Add gdb::string_view 2018-04-09 14:20:46 -04:00
cli-script.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
cli-setshow.c Convert observers to C++ 2018-03-19 09:37:49 -06:00
cli-setshow.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
cli-utils.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
cli-utils.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00