public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Keith Seitz <keiths@redhat.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Record and output access specifiers for nested typedefs
Date: Mon, 16 Oct 2017 21:40:00 -0000	[thread overview]
Message-ID: <d03df701-8d84-291e-deec-f686ae8e62b5@ericsson.com> (raw)
In-Reply-To: <1508189538-6733-1-git-send-email-keiths@redhat.com>

On 2017-10-16 05:32 PM, Keith Seitz wrote:
> On 10/16/2017 12:56 PM, Simon Marchi wrote:
>> On 2017-10-13 03:18 PM, Keith Seitz wrote:
>>> gdb/ChangeLog:
>>>
>>> 	* c-typeprint.c (enum access_specifier): Moved here from
>>> 	c_type_print_base.
>>> 	(output_access_specifier): New function.
>>> 	(c_type_print_base): Consider typedefs when assessing
>>> 	whether access labels are needed.
>>> 	Use output_access_specifier as needed.
>>> 	Output access specifier for typedefs, if needed.
>>> 	* dwarf2read.c (dwarf2_add_typedef): Record DW_AT_accessibility.
>>> 	* gdbtypes.h (struct typedef_field) <is_protected, is_private>: New
>>> 	fields.
>>> 	(TYPE_TYPEDEF_FIELD_PROTECTED, TYPE_TYEPDEF_FIELD_PRIVATE): New
>> "TYPE_TYEPDEF_FIELD_PRIVATE"
>>
> Fixed.
> 
>>> 	accessor macros.
>>>
>>> diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
>>> index 978fcc4..3dc74f9 100644
>>> --- a/gdb/c-typeprint.c
>>> +++ b/gdb/c-typeprint.c
>>> @@ -826,7 +836,42 @@ c_type_print_template_args (const struct type_print_options *flags,
>>>      fputs_filtered (_("] "), stream);
>>>  }
>>>  
>>> -/* Print the name of the type (or the ultimate pointer target,
>>> +/* Output an access specifier to STREAM, if needed.  */
>>> +
>>> +static void
>>> +output_access_specifier (struct ui_file *stream, enum access_specifier &access,
>>> +			 int level, bool is_protected, bool is_private)
>> I would suggest renaming access it to last_access or previous_access.  Could you also document
>> it in the function comment?
> Done.
> 
>> It might also be clearer to have output_access_specifier return the access_specifier,
>> rather than modifying the passed value directly.  Otherwise, it's not really obvious
>> what's happening in the caller.
> Also done.
> 
>>> +  /* Print the name of the type (or the ultimate pointer target,
>> Spurious indent change on that last line.
> Removed.
> 
>>> diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp
>>> index 256fa68..1f6d377 100644
>>> --- a/gdb/testsuite/gdb.cp/classes.exp
>>> +++ b/gdb/testsuite/gdb.cp/classes.exp
>>> @@ -316,6 +316,64 @@ proc test_ptype_class_objects {} {
>>>  	    { field  public "int y;" }
>>>  	    { method public "DynamicBar(int, int);" }
>>>  	}
>>> +
>>> +    # Classes with tyepdefs of different access.
>> "tyepdefs".
> Darn fingers. Fixed.
> 
>>
>>> +
>>> +    cp_test_ptype_class \
>>> +	"class class_with_typedefs" "" "class" "class_with_typedefs" \
>>> +	{
>>> +	    { field protected \
>>> +		  "class_with_typedefs::public_int public_int_;" }
>>> +	    { field protected \
>>> +		  "class_with_typedefs::protected_int protected_int_;" }
>>> +	    { field protected \
>>> +		  "class_with_typedefs::private_int private_int_;" }
>>> +	    { method public "class_with_typedefs(void);" }
>>> +	    { method public "class_with_typedefs::public_int add_public(class_with_typedefs::public_int);" }
>>> +	    { method public \
>>> +		  "class_with_typedefs::public_int add_all(int);" }
>>> +	    { method protected "class_with_typedefs::protected_int add_protected(class_with_typedefs::protected_int);" }
>>> +	    { method private "class_with_typedefs::private_int add_private(class_with_typedefs::private_int);" }
>>> +	    {typedef public "typedef int public_int;" }
>>> +	    {typedef protected "typedef int protected_int;" }
>>> +	    {typedef private "typedef int private_int;" }
>> Add spaces after {, for consistency.
> Also fixed. [How'd I not see that?!]
> 
>>> +    # For the following two cases, we cannot use cp_test_ptype_class.
>>> +    # We need to explicitly check whether the access label was suppressed.
>>> +    set ws {[\ \t\r\n]*}
>> I don't think it's necessary to escape the space.
>>
> Indeed not. Removed.
> 
> Thank you for the reivew.
> 
> Keith

Great, LGTM.

Simon

  reply	other threads:[~2017-10-16 21:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13 19:18 Keith Seitz
2017-10-16 19:57 ` Simon Marchi
2017-10-16 21:32   ` Keith Seitz
2017-10-16 21:40     ` Simon Marchi [this message]
2017-10-17  0:56       ` Keith Seitz
2017-10-17  1:05     ` Pedro Alves
2017-10-17 21:38       ` [PATCH] Issue complaint instead of assert for invalid/unhandled DW_AT_accessibility Keith Seitz
2017-10-18 10:21         ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d03df701-8d84-291e-deec-f686ae8e62b5@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).