On 05/11/18 14:40 -0500, Tom Honermann wrote:
This patch adds recognition of the u8string and u8string_view type aliases to the gdb pretty printer extension.

libstdc++-v3/ChangeLog:

2018-11-04  Tom Honermann  <t...@honermann.net>

    * python/libstdcxx/v6/printers.py (register_type_printers): Add
    type printers for u8string and u8string_view.
    * testsuite/libstdc++-prettyprinters/whatis.cc: Validate
    recognition of u8string.

Tom.

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py 
b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 827c87b70ea..f9e638e210d 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -1554,7 +1554,7 @@ def register_type_printers(obj):
        return

    # Add type printers for typedefs std::string, std::wstring etc.
-    for ch in ('', 'w', 'u16', 'u32'):
+    for ch in ('', 'w', 'u8', 'u16', 'u32'):
        add_one_type_printer(obj, 'basic_string', ch + 'string')
        add_one_type_printer(obj, '__cxx11::basic_string', ch + 'string')
        # Typedefs for __cxx11::basic_string used to be in namespace __cxx11:
@@ -1604,7 +1604,7 @@ def register_type_printers(obj):

    # Add type printers for experimental::basic_string_view typedefs.
    ns = 'experimental::fundamentals_v1::'
-    for ch in ('', 'w', 'u16', 'u32'):
+    for ch in ('', 'w', 'u8', 'u16', 'u32'):
        add_one_type_printer(obj, ns + 'basic_string_view',
                             ns + ch + 'string_view')


I've committed the above change, but not the part below (again, I
don't want to add -fchar8_t to the test, so I'll add a new whatis3.cc
test for C++2a).


diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc 
b/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc
index 90f3994314b..d74bf7c5e9b 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc
@@ -1,5 +1,5 @@
// { dg-do run { target c++11 } }
-// { dg-options "-g -O0" }
+// { dg-options "-g -O0 -fchar8_t" }
// { dg-skip-if "" { *-*-* } { "-D_GLIBCXX_PROFILE" } }

// Copyright (C) 2011-2018 Free Software Foundation, Inc.
@@ -130,6 +130,9 @@ holder<std::cregex_token_iterator> 
cregex_token_iterator_holder;
std::sregex_token_iterator *sregex_token_iterator_ptr;
holder<std::sregex_token_iterator> sregex_token_iterator_holder;
// { dg-final { whatis-test sregex_token_iterator_holder 
"holder<std::sregex_token_iterator>" } }
+std::u8string *u8string_ptr;
+holder<std::u8string> u8string_holder;
+// { dg-final { whatis-test u8string_holder "holder<std::u8string>" } }
std::u16string *u16string_ptr;
holder<std::u16string> u16string_holder;
// { dg-final { whatis-test u16string_holder "holder<std::u16string>" } }
@@ -240,6 +243,8 @@ main()
  placeholder(&cregex_token_iterator_holder);
  placeholder(&sregex_token_iterator_ptr);
  placeholder(&sregex_token_iterator_holder);
+  placeholder(&u8string_ptr);
+  placeholder(&u8string_holder);
  placeholder(&u16string_ptr);
  placeholder(&u16string_holder);
  placeholder(&u32string_ptr);

Reply via email to