[v2,06/11,PR,gdb/14441] gdb: print: implement correct printing of rvalue reference types and values

Message ID 1453229609-20159-7-git-send-email-artemiyv@acm.org
State New, archived
Headers

Commit Message

Artemiy Volkov Jan. 19, 2016, 6:53 p.m. UTC
  This patch provides the ability to print out names of rvalue reference types
and values of those types. This is done in full similarity to regular
references, and as with them, we don't print out "const" suffix because all
rvalue references are const.

./ChangeLog:

2016-01-19  Artemiy Volkov  <artemiyv@acm.org>

        * gdb/c-typeprint.c (c_print_type): Support printing rvalue
        reference types.
        (c_type_print_varspec_prefix): Likewise.
        (c_type_print_modifier): Likewise.
        (c_type_print_varspec_suffix): Likewise.
        (c_type_print_base): Likewise.
        * gdb/c-valprint.c (c_val_print): Support printing rvalue
        reference values.
        (c_value_print): Likewise.
---
 gdb/c-typeprint.c | 10 ++++++----
 gdb/c-valprint.c  |  4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)
  

Comments

Keith Seitz Feb. 19, 2016, 6:56 p.m. UTC | #1
On 01/19/2016 10:53 AM, Artemiy Volkov wrote:
> 2016-01-19  Artemiy Volkov  <artemiyv@acm.org>
> 
>         * gdb/c-typeprint.c (c_print_type): Support printing rvalue
>         reference types.
>         (c_type_print_varspec_prefix): Likewise.
>         (c_type_print_modifier): Likewise.
>         (c_type_print_varspec_suffix): Likewise.
>         (c_type_print_base): Likewise.
>         * gdb/c-valprint.c (c_val_print): Support printing rvalue
>         reference values.
>         (c_value_print): Likewise.

More condensing of functions/changelogs:

	* c-typeprint.c (c_print_type, c_type_print_varspec)
	(c_type_print_modifier, c_type_print_varspec_suffix)
	(c_type_print_base): Suppport rvalue references.

Keith
  

Patch

diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 762c027..67129ad 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -112,7 +112,7 @@  c_print_type (struct type *type,
 		      && !TYPE_VECTOR (type))
 		  || code == TYPE_CODE_MEMBERPTR
 		  || code == TYPE_CODE_METHODPTR
-		  || code == TYPE_CODE_REF)))
+                 || TYPE_REFERENCE (type))))
 	fputs_filtered (" ", stream);
       need_post_space = (varstring != NULL && strcmp (varstring, "") != 0);
       c_type_print_varspec_prefix (type, stream, show, 0, need_post_space,
@@ -341,9 +341,10 @@  c_type_print_varspec_prefix (struct type *type,
       break;
 
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
 				   stream, show, 1, 0, flags);
-      fprintf_filtered (stream, "&");
+      fprintf_filtered (stream, TYPE_CODE(type) == TYPE_CODE_REF ? "&" : "&&");
       c_type_print_modifier (type, stream, 1, need_post_space);
       break;
 
@@ -409,8 +410,7 @@  c_type_print_modifier (struct type *type, struct ui_file *stream,
   /* We don't print `const' qualifiers for references --- since all
      operators affect the thing referenced, not the reference itself,
      every reference is `const'.  */
-  if (TYPE_CONST (type)
-      && TYPE_CODE (type) != TYPE_CODE_REF)
+  if (TYPE_CONST (type) && !TYPE_REFERENCE (type))
     {
       if (need_pre_space)
 	fprintf_filtered (stream, " ");
@@ -725,6 +725,7 @@  c_type_print_varspec_suffix (struct type *type,
 
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
 				   show, 1, 0, flags);
       break;
@@ -892,6 +893,7 @@  c_type_print_base (struct type *type, struct ui_file *stream,
     case TYPE_CODE_PTR:
     case TYPE_CODE_MEMBERPTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
     case TYPE_CODE_METHODPTR:
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index e210e99..116686f 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -538,6 +538,7 @@  c_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
     case TYPE_CODE_ENUM:
     case TYPE_CODE_FLAGS:
     case TYPE_CODE_FUNC:
@@ -583,8 +584,7 @@  c_value_print (struct value *val, struct ui_file *stream,
   val_type = value_type (val);
   type = check_typedef (val_type);
 
-  if (TYPE_CODE (type) == TYPE_CODE_PTR
-      || TYPE_CODE (type) == TYPE_CODE_REF)
+  if (TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_REFERENCE (type))
     {
       /* Hack:  remove (char *) for char strings.  Their
          type is indicated by the quoted string anyway.