From patchwork Mon Jun 6 19:22:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artemiy Volkov X-Patchwork-Id: 12807 Received: (qmail 25626 invoked by alias); 6 Jun 2016 19:23:01 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 25447 invoked by uid 89); 6 Jun 2016 19:23:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:type_i, sk:!type_i, sk:!TYPE_I, sk:TYPE_I X-HELO: mail-lf0-f66.google.com Received: from mail-lf0-f66.google.com (HELO mail-lf0-f66.google.com) (209.85.215.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 06 Jun 2016 19:22:54 +0000 Received: by mail-lf0-f66.google.com with SMTP id h68so14390607lfh.3 for ; Mon, 06 Jun 2016 12:22:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=u0QXFd6kIXPPVvv5QJ/vIMeZ0VuUUB1WZ7npTi58HOk=; b=CG6S0Uv/kkSPdmvmZVjiLaxZVclotgP/0TSG09v3P0oPWjcTWe2AHyYqUq69bshflT D53QzeGIh+dgzgekI5wmKNuKFItqSL6YlR7UBuwww4sfqurYxcK0XTQ7EuVuY2PVZdiR P4laY4Y4D4Qh5reQdUSZr1J2RuDCu8jo5MJZZ7NfIXmzz62UKkg7tizHVR0BmKgruQnE 2cVcfr2LCkuu7TOCc1jkVfs7xEMMS0eQ4H9GQcWks62wTJzvVITH0HNRFGI+1TGFRyAP E8N4a5FmziOJvDOUtTYVsYrzmhSSzFtfFhHSG+V/GgQ3KKtg1W92tIty4r+ln0DAK0jJ jcLw== X-Gm-Message-State: ALyK8tLW9FQ5c92eZ2lqi6LnoCqxqvdMPaL50TbLSXJw+881km74zasB2GdDVkYNmzGJog== X-Received: by 10.25.146.66 with SMTP id u63mr1504867lfd.42.1465240970992; Mon, 06 Jun 2016 12:22:50 -0700 (PDT) Received: from localhost.localdomain (broadband-90-154-70-138.nationalcablenetworks.ru. [90.154.70.138]) by smtp.gmail.com with ESMTPSA id jv7sm1970253lbc.4.2016.06.06.12.22.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jun 2016 12:22:50 -0700 (PDT) From: Artemiy Volkov To: gdb-patches@sourceware.org Cc: palves@redhat.com, keiths@redhat.com, Artemiy Volkov Subject: [PATCH v5 06/11] [PR gdb/14441] gdb: print: implement correct printing of rvalue reference types and values Date: Mon, 6 Jun 2016 22:22:20 +0300 Message-Id: <20160606192225.12384-7-artemiyv@acm.org> In-Reply-To: <20160606192225.12384-1-artemiyv@acm.org> References: <1458593958-25656-1-git-send-email-artemiyv@acm.org> <20160606192225.12384-1-artemiyv@acm.org> X-IsSubscribed: yes 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. gdb/ChangeLog: 2016-06-06 Artemiy Volkov PR gdb/14441 * c-typeprint.c (c_print_type, c_type_print_varspec_prefix) (c_type_print_modifier, c_type_print_varspec_suffix) (c_type_print_base): Support printing rvalue reference types. * c-valprint.c (c_val_print, c_value_print): Support printing rvalue reference values. --- gdb/c-typeprint.c | 10 ++++++---- gdb/c-valprint.c | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index ed16fc3..569a803 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_IS_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; @@ -410,8 +411,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_IS_REFERENCE (type)) { if (need_pre_space) fprintf_filtered (stream, " "); @@ -726,6 +726,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; @@ -894,6 +895,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 637acf0..f2e4fa2 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -540,6 +540,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: @@ -585,8 +586,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_IS_REFERENCE (type)) { /* Hack: remove (char *) for char strings. Their type is indicated by the quoted string anyway. @@ -637,7 +637,7 @@ c_value_print (struct value *val, struct ui_file *stream, if (is_ref) { - val = value_ref (value_ind (val)); + val = value_ref (value_ind (val), refcode); type = value_type (val); }