This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Record and output access specifiers for nested typedefs


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]