public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Nathan Sidwell <nathan@acm.org>, marxin <mliska@suse.cz>,
	gcc-patches@gcc.gnu.org
Cc: hubicka@ucw.cz
Subject: Re: [PATCH 3/8] Simplify representation of locations of a block.
Date: Fri, 28 Apr 2017 16:40:00 -0000	[thread overview]
Message-ID: <e4271f55-56b9-0122-dfb9-42ea520e2d67@gmail.com> (raw)
In-Reply-To: <00fc8b09-85b6-eae2-e439-410b76e16f92@acm.org>

On 04/28/2017 05:47 AM, Nathan Sidwell wrote:
> On 04/21/2017 10:02 AM, marxin wrote:
>> gcc/ChangeLog:
>>
>> 2017-04-26  Martin Liska  <mliska@suse.cz>
>>
>>     * gcov.c (struct block_location_info): New struct.
>>     (process_file): Fill up the new structure.
>>     (read_graph_file): Replace usage of encoding by the newly added
>>     struct.
>>     (add_line_counts): Likewise.
>>     (accumulate_line_counts): Remove usage of the union.
>>     (function_info::function_info): New function.
>>     (function_info::~function_info): Likewise.
>>     (process_file): Call delete instead of release_function.
>>     (release_function): Release the function.
>>     (release_structures): Call delete instead of release_function.
>>     (solve_flow_graph): Replace usage of num_blocks.
>>     (find_exception_blocks): Likewise.
>>     (output_lines): Fix GNU coding style.
>
>> diff --git a/gcc/gcov.c b/gcc/gcov.c
>> index 63f6a75f1af..7400cdee110 100644
>> --- a/gcc/gcov.c
>> +++ b/gcc/gcov.c
>> @@ -114,6 +114,16 @@ typedef struct arc_info
>>     struct arc_info *pred_next;
>>   } arc_t;
>>   +struct block_location_info
>
> /* needs comment.  */
>
>
>
>> @@ -427,9 +429,31 @@ static void output_lines (FILE *, const source_t *);
>>   static char *make_gcov_file_name (const char *, const char *);
>>   static char *mangle_name (const char *, char *);
>>   static void release_structures (void);
>> -static void release_function (function_t *);
>>   extern int main (int, char **);
>>   +function_info::function_info ()
>> +{
>> +  memset (this, 0, sizeof (*this));
>
> EW.  ok with a comment about function_info's c++11's PoDness.

Unless it's some other kind of vector, the patch adds a vector
member to the class, which makes it not a PoD.(*)

In addition, it would make the class ever so slightly safer to
use if it were made non-copyable (by declaring its copy ctor
private).  Otherwise, accidentally creating a copy of an object
of the type could lead to a double free in the newly added dtor.

Martin

[*]  Strictly speaking using memset to initialize pointers to
null isn't guaranteed to work on targets where a null pointer
isn't all bits clear.  I don't know if GCC is meant to build
on such targets but the code would be cleaner (albeit more
verbose) if it defeault-initialized each member in the ctor
initializer list.

  reply	other threads:[~2017-04-28 16:28 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28  9:31 [PATCH 0/8] GCOV improvements marxin
2017-04-28  9:31 ` [PATCH 5/8] Make gcno more precise about BBs really belonging to a line (PR gcov-profile/79891) marxin
2017-04-28 11:47   ` Nathan Sidwell
2017-04-28 13:06     ` Martin Liška
2017-04-28  9:31 ` [PATCH 2/8] Remove .gcno file when compilation does not success (PR driver/56469) marxin
2017-04-28 12:00   ` Nathan Sidwell
2017-04-28  9:31 ` [PATCH 1/8] gcno file: do not stream block flags (PR gcov-profile/80031) marxin
2017-04-28 11:48   ` Nathan Sidwell
2017-04-28  9:31 ` [PATCH 6/8] Fix format_gcov to not print misleading values (PR gcov-profile/53915) marxin
2017-04-28 11:38   ` Nathan Sidwell
2017-04-28  9:31 ` [PATCH 4/8] Introduce new option -w which shows verbose informations marxin
2017-04-28 11:41   ` Nathan Sidwell
2017-04-28 10:58 ` [PATCH 7/8] Sort options of gcov, gcov-dump and gcov-tool both in --help and documentation marxin
2017-04-28 11:32   ` Nathan Sidwell
2017-04-28 11:25 ` [PATCH 8/8] Enhance documentation of gcov marxin
2017-04-28 11:35   ` Nathan Sidwell
2017-04-29  3:20   ` Martin Sebor
2018-07-22  8:40     ` Gerald Pfeifer
2017-04-28 11:26 ` [PATCH 3/8] Simplify representation of locations of a block marxin
2017-04-28 11:57   ` Nathan Sidwell
2017-04-28 16:40     ` Martin Sebor [this message]
2017-04-28 17:48       ` Nathan Sidwell
2017-05-02 15:38         ` [PATCH] Fix documentation and a ctor in gcov.c Martin Liška
2017-05-03 13:20           ` Nathan Sidwell
2017-04-28 19:13       ` [PATCH 3/8] Simplify representation of locations of a block Pedro Alves
2017-04-28 19:46         ` Martin Sebor
2017-04-28 20:07         ` Pedro Alves
2017-04-28 12:03 ` [PATCH 0/8] GCOV improvements Nathan Sidwell
2017-04-28 12:16   ` Martin Liška
2017-04-29 16:31     ` Gerald Pfeifer

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=e4271f55-56b9-0122-dfb9-42ea520e2d67@gmail.com \
    --to=msebor@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=mliska@suse.cz \
    --cc=nathan@acm.org \
    /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).