From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14808 invoked by alias); 4 Dec 2019 16:39:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 14264 invoked by uid 89); 4 Dec 2019 16:39:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1814, timer X-HELO: mail-pl1-f194.google.com Received: from mail-pl1-f194.google.com (HELO mail-pl1-f194.google.com) (209.85.214.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Dec 2019 16:39:47 +0000 Received: by mail-pl1-f194.google.com with SMTP id w7so3369453plz.12 for ; Wed, 04 Dec 2019 08:39:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=wGQeewgEAbIITHFCECZE3k/oNsp7ENr8QkUliFwNRV8=; b=V4vVPG8gJ36TPGsSpQvYYnrllw8Lrp0j0/T8mK2zOpq7OXBGiSDc/FT+EJGXod6Qzc 7KGung6wgUCab59Y0s+bfncR7hXo185cEOGyICprgVCOkdhNkylMUN6lPL7gQpVBzLyZ 5aEDefQoE7XbWuAsIgdC5eQitDCiuvJ7SrFubgWHYWk4gM59cGH+MNldhYdgDvtJEgvB 2LVff4l95MVubxMbRyrgbK4VDEgW/7CHaV9pZkSOsSYeC0V1Uf42o3GJXMnu3pi1rG0Q nzW1ODQZGo9UWWRXBV7kzwzHvhLxexiLP4I7AzCEQpDvr4njVAoZCsOgrBNSMwHzOjb6 V65A== Return-Path: Received: from [192.168.0.41] (75-166-111-174.hlrn.qwest.net. [75.166.111.174]) by smtp.gmail.com with ESMTPSA id o7sm9505154pfg.138.2019.12.04.08.39.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Dec 2019 08:39:44 -0800 (PST) Subject: Re: [PATCH 06/49] timevar.h: add auto_client_timevar class To: David Malcolm , gcc-patches@gcc.gnu.org References: <1573867416-55618-1-git-send-email-dmalcolm@redhat.com> <1573867416-55618-7-git-send-email-dmalcolm@redhat.com> From: Martin Sebor Message-ID: <85b1dcdc-84a8-7270-e710-bb6062c1f5d4@gmail.com> Date: Wed, 04 Dec 2019 16:39:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1573867416-55618-7-git-send-email-dmalcolm@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-12/txt/msg00222.txt.bz2 On 11/15/19 6:22 PM, David Malcolm wrote: > This patch adds a class "auto_client_timevar", similar to auto_timevar, > but for plugins to use on their own timing items that aren't in > timevar.def > > gcc/ChangeLog: > * timevar.h (class auto_client_timevar): New class. > --- > gcc/timevar.h | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/gcc/timevar.h b/gcc/timevar.h > index ef404d0..d053ab7 100644 > --- a/gcc/timevar.h > +++ b/gcc/timevar.h > @@ -256,6 +256,39 @@ class auto_timevar > timevar_id_t m_tv; > }; > > +/* An RAII class analogous to auto_timevar, but for a client item, > + for use by plugins. */ > + > +class auto_client_timevar > +{ > + public: > + auto_client_timevar (timer *t, const char *item_name) > + : m_timer (t) > + { > + if (m_timer) > + m_timer->push_client_item (item_name); > + } > + > + explicit auto_client_timevar (const char *item_name) > + : m_timer (g_timer) > + { > + if (m_timer) > + m_timer->push_client_item (item_name); > + } > + > + ~auto_client_timevar () > + { > + if (m_timer) > + m_timer->pop_client_item (); > + } > + > + private: > + // Private to disallow copies. > + auto_client_timevar (const auto_client_timevar &); I don't know why it's important to disallow making copies of these classes (they look safe to copy) but usually it goes along with assignment so I would suggest adding a comment with a rationale and (perhaps also) disabling assignment. Martin PS I see auto_timevar is also assignable but not copyable. It's a common mistake to make to forget about one or the other (or both) so if it's intentional it helps to document it. > + > + timer *m_timer; > +}; > + > extern void print_time (const char *, long); > > #endif /* ! GCC_TIMEVAR_H */ >