Re: [RFA 01/42] Use new and delete for buildsym_compunit

Simon Marchi
2018-07-07T02:31:35Z

On 2018-07-05 02:49 PM, Keith Seitz wrote:
> Hi, Tom,
>
> I've got one general question:
>
> On 05/22/2018 09:58 PM, Tom Tromey wrote:
>> This changes buildsym_compunit to use new and delete.
>>
>> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
>> index 5d38cb250f..9863e4ea1e 100644
>> --- a/gdb/buildsym.c
>> +++ b/gdb/buildsym.c
>> @@ -107,24 +136,24 @@ struct buildsym_compunit
>> Files are added to the front of the list.
>> This is important mostly for the language determination hacks we use,
>> which iterate over previously added files. */
>> - struct subfile *subfiles;
>> + struct subfile *subfiles = nullptr;
>>
>> /* The subfile of the main source file. */
>> - struct subfile *main_subfile;
>> + struct subfile *main_subfile = nullptr;
>>
>> /* E.g., DW_AT_comp_dir if DWARF. Space for this is malloc'd. */
>> char *comp_dir;
>>
>> /* Space for this is not malloc'd, and is assumed to have at least
>> the same lifetime as objfile. */
>> - const char *producer;
>> + const char *producer = nullptr;
>>
>> /* Space for this is not malloc'd, and is assumed to have at least
>> the same lifetime as objfile. */
>> - const char *debugformat;
>> + const char *debugformat = nullptr;
>>
>> /* The compunit we are building. */
>> - struct compunit_symtab *compunit_symtab;
>> + struct compunit_symtab *compunit_symtab = nullptr;
>>
>> /* Language of this compunit_symtab. */
>> enum language language;
>
> By the end of the series, this struct declaration is moved to buildsym.h and a bunch of new, private data is added. All those data members are named "m_XYZ" whereas the above variable names are never receive the "m_" treatment.
>
> Since these variables will later become private, should they not also (some time) be renamed?
> [I think this should/could be a follow-on patch -- no changes needed here.]

In any case, this patch on its own LGTM, since the fields are still public.

Simon