From patchwork Mon Sep 30 20:39:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 279258 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 11C5F2C010A for ; Tue, 1 Oct 2013 06:39:26 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=O1v9tHWTsiuY2L3j 8GttZxSljknz4i+XFuKaKopnjxtbUOGMQIoa7Gxf3sH2qekwIUEWgBkwdiPlADLX IMr6Hy89yCOZRltoKcr5d12uyY1lhdwkJd2prAi/QViakrf+gQati36stncWomg3 Ii1LgN2I6W9btgMF6zVURAGWSqE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=1xcREDweicqR0fQCKQ22g1 nWMsY=; b=UxC+9kotDqR4u1lyWdrvv5VilWtZy0zk5blNitpXLvNhtq4+jt7Gd/ yt9GrBNcVG1Cg1vWB94hKuAP4ezbwuVW9OzapClbpoPj0d6arPKlGXXWwNk2M+n4 GE4Kut5lqE0RpDYXTnorrr//xAC7Hr2j5OxxZnOt4cBm7eOlk+oWE= Received: (qmail 6127 invoked by alias); 30 Sep 2013 20:39:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 6115 invoked by uid 89); 30 Sep 2013 20:39:19 -0000 Received: from mail-we0-f171.google.com (HELO mail-we0-f171.google.com) (74.125.82.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 30 Sep 2013 20:39:18 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=ALL_TRUSTED, AWL, BAYES_00, FREEMAIL_FROM autolearn=ham version=3.3.2 X-HELO: mail-we0-f171.google.com Received: by mail-we0-f171.google.com with SMTP id p61so109274wes.30 for ; Mon, 30 Sep 2013 13:39:13 -0700 (PDT) X-Received: by 10.180.229.103 with SMTP id sp7mr15685243wic.2.1380573553787; Mon, 30 Sep 2013 13:39:13 -0700 (PDT) Received: from localhost ([2.28.235.51]) by mx.google.com with ESMTPSA id fb9sm4552860wid.7.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 30 Sep 2013 13:39:13 -0700 (PDT) From: Richard Sandiford To: Richard Biener Mail-Followup-To: Richard Biener , GCC Patches , Michael Matz , Trevor Saunders , Jeff Law , rdsandiford@googlemail.com Cc: GCC Patches , Michael Matz , Trevor Saunders , Jeff Law Subject: Re: RFA: Use "m_foo" rather than "foo_" for member variables References: <20130904145911.GC17620@tsaunders-iceball.corp.tor1.mozilla.com> <522759C8.5040802@redhat.com> <20130911000350.GA28492@tsaunders-iceball.corp.tor1.mozilla.com> <52389CB1.60504@redhat.com> <5239126A.6010702@redhat.com> <5239D985.4080205@redhat.com> <87fvt065ro.fsf@talisman.default> <20130920120550.GA24624@tsaunders-iceball.corp.tor1.mozilla.com> <87wqm0kna6.fsf_-_@talisman.default> Date: Mon, 30 Sep 2013 21:39:11 +0100 In-Reply-To: (Richard Biener's message of "Mon, 30 Sep 2013 14:05:37 +0200") Message-ID: <87ob7akpsg.fsf@talisman.default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Richard Biener writes: > On Sun, Sep 29, 2013 at 11:08 AM, Richard Sandiford > wrote: >> Michael Matz writes: >>>Trever Saunders writes: >>>> Richard Biener writes: >>>> > Btw, I've come around multiple coding-styles in the past and I >>>> > definitely would prefer m_mode / m_count to mark members vs. mode_ and >>>> > count_. (and s_XXX for static members IIRC). >>>> >>>> I'd prefer m_/s_foo for members / static things too fwiw. >>> >>> Me as well. It's still ugly, but not so unsymmetric as the trailing >>> underscore. >> >> Well, I'm not sure how I came to be the one writing these patches, >> but I suppose I prefer m_foo too. So how about the attached? >> >> The first patch has changes to the coding conventions. I added >> some missing spaces while there. >> >> The second patch has the mechanical code changes. The reason for >> yesterday's mass adding of spaces was because the second patch would >> have been pretty inconsistent otherwise. >> >> Tested on x86_64-linux-gnu. > > Ok. Applied, thanks. I was only looking for private and protected members, so I ended up missing vec. I installed the patch below as an obvious follow-up. Tested on x86_64-linux-gnu. There are some other uses foo_, but many of them seem to date from before the C++ switchover. Richard gcc/ * vec.h (vec_prefix, vec): Prefix member names with "m_". * vec.c (vec_prefix::calculate_allocation): Update accordingly. Index: gcc/vec.c =================================================================== --- gcc/vec.c 2013-09-27 09:16:58.010299213 +0100 +++ gcc/vec.c 2013-09-30 18:09:02.892316820 +0100 @@ -183,8 +183,8 @@ vec_prefix::calculate_allocation (vec_pr if (pfx) { - alloc = pfx->alloc_; - num = pfx->num_; + alloc = pfx->m_alloc; + num = pfx->m_num; } else if (!reserve) /* If there's no vector, and we've not requested anything, then we Index: gcc/vec.h =================================================================== --- gcc/vec.h 2013-09-30 18:06:22.236575959 +0100 +++ gcc/vec.h 2013-09-30 18:06:22.305576705 +0100 @@ -235,8 +235,8 @@ struct vec_prefix friend struct va_heap; friend struct va_stack; - unsigned alloc_; - unsigned num_; + unsigned m_alloc; + unsigned m_num; }; template struct vec; @@ -285,7 +285,7 @@ va_heap::reserve (vecvecpfx_ : 0, reserve, exact); + = vec_prefix::calculate_allocation (v ? &v->m_vecpfx : 0, reserve, exact); if (!alloc) { release (v); @@ -293,7 +293,7 @@ va_heap::reserve (vecvecpfx_.release_overhead (); + v->m_vecpfx.release_overhead (); size_t size = vec::embedded_size (alloc); unsigned nelem = v ? v->length () : 0; @@ -301,7 +301,7 @@ va_heap::reserve (vecembedded_init (alloc, nelem); if (GATHER_STATISTICS) - v->vecpfx_.register_overhead (size FINAL_PASS_MEM_STAT); + v->m_vecpfx.register_overhead (size FINAL_PASS_MEM_STAT); } @@ -315,7 +315,7 @@ va_heap::release (vecvecpfx_.release_overhead (); + v->m_vecpfx.release_overhead (); ::free (v); v = NULL; } @@ -364,7 +364,7 @@ va_gc::reserve (vec *&v, MEM_STAT_DECL) { unsigned alloc - = vec_prefix::calculate_allocation (v ? &v->vecpfx_ : 0, reserve, exact); + = vec_prefix::calculate_allocation (v ? &v->m_vecpfx : 0, reserve, exact); if (!alloc) { ::ggc_free (v); @@ -433,9 +433,9 @@ void unregister_stack_vec (unsigned); va_stack::alloc (vec &v, unsigned nelems, vec *space) { - v.vec_ = space; - register_stack_vec (static_cast (v.vec_)); - v.vec_->embedded_init (nelems, 0); + v.m_vec = space; + register_stack_vec (static_cast (v.m_vec)); + v.m_vec->embedded_init (nelems, 0); } @@ -462,16 +462,16 @@ va_stack::reserve (vecvecpfx_.num_; + nelems += v->m_vecpfx.m_num; vec *oldvec = v; v = NULL; va_heap::reserve (reinterpret_cast *&>(v), nelems, exact PASS_MEM_STAT); if (v && oldvec) { - v->vecpfx_.num_ = oldvec->length (); - memcpy (v->vecdata_, - oldvec->vecdata_, + v->m_vecpfx.m_num = oldvec->length (); + memcpy (v->m_vecdata, + oldvec->m_vecdata, oldvec->length () * sizeof (T)); } } @@ -562,11 +562,11 @@ struct vnull struct GTY((user)) vec { public: - unsigned allocated (void) const { return vecpfx_.alloc_; } - unsigned length (void) const { return vecpfx_.num_; } - bool is_empty (void) const { return vecpfx_.num_ == 0; } - T *address (void) { return vecdata_; } - const T *address (void) const { return vecdata_; } + unsigned allocated (void) const { return m_vecpfx.m_alloc; } + unsigned length (void) const { return m_vecpfx.m_num; } + bool is_empty (void) const { return m_vecpfx.m_num == 0; } + T *address (void) { return m_vecdata; } + const T *address (void) const { return m_vecdata; } const T &operator[] (unsigned) const; T &operator[] (unsigned); T &last (void); @@ -601,8 +601,8 @@ struct GTY((user)) vec /* FIXME - These fields should be private, but we need to cater to compilers that have stricter notions of PODness for types. */ - vec_prefix vecpfx_; - T vecdata_[1]; + vec_prefix m_vecpfx; + T m_vecdata[1]; }; @@ -816,16 +816,16 @@ vec_safe_splice (vec *&d inline const T & vec::operator[] (unsigned ix) const { - gcc_checking_assert (ix < vecpfx_.num_); - return vecdata_[ix]; + gcc_checking_assert (ix < m_vecpfx.m_num); + return m_vecdata[ix]; } template inline T & vec::operator[] (unsigned ix) { - gcc_checking_assert (ix < vecpfx_.num_); - return vecdata_[ix]; + gcc_checking_assert (ix < m_vecpfx.m_num); + return m_vecdata[ix]; } @@ -835,8 +835,8 @@ vec::operator[] (unsigne inline T & vec::last (void) { - gcc_checking_assert (vecpfx_.num_ > 0); - return (*this)[vecpfx_.num_ - 1]; + gcc_checking_assert (m_vecpfx.m_num > 0); + return (*this)[m_vecpfx.m_num - 1]; } @@ -850,7 +850,7 @@ vec::last (void) inline bool vec::space (unsigned nelems) const { - return vecpfx_.alloc_ - vecpfx_.num_ >= nelems; + return m_vecpfx.m_alloc - m_vecpfx.m_num >= nelems; } @@ -865,9 +865,9 @@ vec::space (unsigned nel inline bool vec::iterate (unsigned ix, T *ptr) const { - if (ix < vecpfx_.num_) + if (ix < m_vecpfx.m_num) { - *ptr = vecdata_[ix]; + *ptr = m_vecdata[ix]; return true; } else @@ -891,9 +891,9 @@ vec::iterate (unsigned i inline bool vec::iterate (unsigned ix, T **ptr) const { - if (ix < vecpfx_.num_) + if (ix < m_vecpfx.m_num) { - *ptr = CONST_CAST (T *, &vecdata_[ix]); + *ptr = CONST_CAST (T *, &m_vecdata[ix]); return true; } else @@ -916,7 +916,7 @@ vec::copy (ALONE_MEM_STA { vec_alloc (new_vec, len PASS_MEM_STAT); new_vec->embedded_init (len, len); - memcpy (new_vec->address (), vecdata_, sizeof (T) * len); + memcpy (new_vec->address (), m_vecdata, sizeof (T) * len); } return new_vec; } @@ -934,7 +934,7 @@ vec::splice (vec::splice (vec::quick_push (const T &obj) { gcc_checking_assert (space (1)); - T *slot = &vecdata_[vecpfx_.num_++]; + T *slot = &m_vecdata[m_vecpfx.m_num++]; *slot = obj; return slot; } @@ -969,7 +969,7 @@ vec::quick_push (const T vec::pop (void) { gcc_checking_assert (length () > 0); - return vecdata_[--vecpfx_.num_]; + return m_vecdata[--m_vecpfx.m_num]; } @@ -981,7 +981,7 @@ vec::pop (void) vec::truncate (unsigned size) { gcc_checking_assert (length () >= size); - vecpfx_.num_ = size; + m_vecpfx.m_num = size; } @@ -994,8 +994,8 @@ vec::quick_insert (unsig { gcc_checking_assert (length () < allocated ()); gcc_checking_assert (ix <= length ()); - T *slot = &vecdata_[ix]; - memmove (slot + 1, slot, (vecpfx_.num_++ - ix) * sizeof (T)); + T *slot = &m_vecdata[ix]; + memmove (slot + 1, slot, (m_vecpfx.m_num++ - ix) * sizeof (T)); *slot = obj; } @@ -1009,8 +1009,8 @@ vec::quick_insert (unsig vec::ordered_remove (unsigned ix) { gcc_checking_assert (ix < length ()); - T *slot = &vecdata_[ix]; - memmove (slot, slot + 1, (--vecpfx_.num_ - ix) * sizeof (T)); + T *slot = &m_vecdata[ix]; + memmove (slot, slot + 1, (--m_vecpfx.m_num - ix) * sizeof (T)); } @@ -1022,7 +1022,7 @@ vec::ordered_remove (uns vec::unordered_remove (unsigned ix) { gcc_checking_assert (ix < length ()); - vecdata_[ix] = vecdata_[--vecpfx_.num_]; + m_vecdata[ix] = m_vecdata[--m_vecpfx.m_num]; } @@ -1034,9 +1034,9 @@ vec::unordered_remove (u vec::block_remove (unsigned ix, unsigned len) { gcc_checking_assert (ix + len <= length ()); - T *slot = &vecdata_[ix]; - vecpfx_.num_ -= len; - memmove (slot, slot + len, (vecpfx_.num_ - ix) * sizeof (T)); + T *slot = &m_vecdata[ix]; + m_vecpfx.m_num -= len; + memmove (slot, slot + len, (m_vecpfx.m_num - ix) * sizeof (T)); } @@ -1100,7 +1100,7 @@ vec::lower_bound (T obj, vec::embedded_size (unsigned alloc) { typedef vec vec_embedded; - return offsetof (vec_embedded, vecdata_) + alloc * sizeof (T); + return offsetof (vec_embedded, m_vecdata) + alloc * sizeof (T); } @@ -1111,8 +1111,8 @@ vec::embedded_size (unsi inline void vec::embedded_init (unsigned alloc, unsigned num) { - vecpfx_.alloc_ = alloc; - vecpfx_.num_ = num; + m_vecpfx.m_alloc = alloc; + m_vecpfx.m_num = num; } @@ -1123,8 +1123,8 @@ vec::embedded_init (unsi inline void vec::quick_grow (unsigned len) { - gcc_checking_assert (length () <= len && len <= vecpfx_.alloc_); - vecpfx_.num_ = len; + gcc_checking_assert (length () <= len && len <= m_vecpfx.m_alloc); + m_vecpfx.m_num = len; } @@ -1229,22 +1229,22 @@ struct vec /* Vector operations. */ bool exists (void) const - { return vec_ != NULL; } + { return m_vec != NULL; } bool is_empty (void) const - { return vec_ ? vec_->is_empty () : true; } + { return m_vec ? m_vec->is_empty () : true; } unsigned length (void) const - { return vec_ ? vec_->length () : 0; } + { return m_vec ? m_vec->length () : 0; } T *address (void) - { return vec_ ? vec_->vecdata_ : NULL; } + { return m_vec ? m_vec->m_vecdata : NULL; } const T *address (void) const - { return vec_ ? vec_->vecdata_ : NULL; } + { return m_vec ? m_vec->m_vecdata : NULL; } const T &operator[] (unsigned ix) const - { return (*vec_)[ix]; } + { return (*m_vec)[ix]; } bool operator!=(const vec &other) const { return !(*this == other); } @@ -1253,13 +1253,13 @@ struct vec { return address () == other.address (); } T &operator[] (unsigned ix) - { return (*vec_)[ix]; } + { return (*m_vec)[ix]; } T &last (void) - { return vec_->last (); } + { return m_vec->last (); } bool space (int nelems) const - { return vec_ ? vec_->space (nelems) : nelems == 0; } + { return m_vec ? m_vec->space (nelems) : nelems == 0; } bool iterate (unsigned ix, T *p) const; bool iterate (unsigned ix, T **p) const; @@ -1290,7 +1290,7 @@ struct vec /* FIXME - This field should be private, but we need to cater to compilers that have stricter notions of PODness for types. */ - vec *vec_; + vec *m_vec; }; @@ -1393,8 +1393,8 @@ #define vec_stack_alloc(T,V,N) \ inline bool vec::iterate (unsigned ix, T *ptr) const { - if (vec_) - return vec_->iterate (ix, ptr); + if (m_vec) + return m_vec->iterate (ix, ptr); else { *ptr = 0; @@ -1416,8 +1416,8 @@ vec::iterate (unsigned ix, inline bool vec::iterate (unsigned ix, T **ptr) const { - if (vec_) - return vec_->iterate (ix, ptr); + if (m_vec) + return m_vec->iterate (ix, ptr); else { *ptr = 0; @@ -1457,7 +1457,7 @@ vec::copy (ALONE_MEM_STAT_ { vec new_vec = vNULL; if (length ()) - new_vec.vec_ = vec_->copy (); + new_vec.m_vec = m_vec->copy (); return new_vec; } @@ -1477,7 +1477,7 @@ vec::reserve (unsigned nel { bool extend = nelems ? !space (nelems) : false; if (extend) - A::reserve (vec_, nelems, exact PASS_MEM_STAT); + A::reserve (m_vec, nelems, exact PASS_MEM_STAT); return extend; } @@ -1504,7 +1504,7 @@ vec::reserve_exact (unsign inline void vec::create (unsigned nelems MEM_STAT_DECL) { - vec_ = NULL; + m_vec = NULL; if (nelems > 0) reserve_exact (nelems PASS_MEM_STAT); } @@ -1516,8 +1516,8 @@ vec::create (unsigned nele inline void vec::release (void) { - if (vec_) - A::release (vec_); + if (m_vec) + A::release (m_vec); } @@ -1530,8 +1530,8 @@ vec::release (void) inline void vec::splice (vec &src) { - if (src.vec_) - vec_->splice (*(src.vec_)); + if (src.m_vec) + m_vec->splice (*(src.m_vec)); } @@ -1560,7 +1560,7 @@ vec::safe_splice (vec::quick_push (const T &obj) { - return vec_->quick_push (obj); + return m_vec->quick_push (obj); } @@ -1583,7 +1583,7 @@ vec::safe_push (const T &o inline T & vec::pop (void) { - return vec_->pop (); + return m_vec->pop (); } @@ -1594,8 +1594,8 @@ vec::pop (void) inline void vec::truncate (unsigned size) { - if (vec_) - vec_->truncate (size); + if (m_vec) + m_vec->truncate (size); else gcc_checking_assert (size == 0); } @@ -1612,7 +1612,7 @@ vec::safe_grow (unsigned l unsigned oldlen = length (); gcc_checking_assert (oldlen <= len); reserve_exact (len - oldlen PASS_MEM_STAT); - vec_->quick_grow (len); + m_vec->quick_grow (len); } @@ -1637,8 +1637,8 @@ vec::safe_grow_cleared (un inline void vec::quick_grow (unsigned len) { - gcc_checking_assert (vec_); - vec_->quick_grow (len); + gcc_checking_assert (m_vec); + m_vec->quick_grow (len); } @@ -1650,8 +1650,8 @@ vec::quick_grow (unsigned inline void vec::quick_grow_cleared (unsigned len) { - gcc_checking_assert (vec_); - vec_->quick_grow_cleared (len); + gcc_checking_assert (m_vec); + m_vec->quick_grow_cleared (len); } @@ -1662,7 +1662,7 @@ vec::quick_grow_cleared (u inline void vec::quick_insert (unsigned ix, const T &obj) { - vec_->quick_insert (ix, obj); + m_vec->quick_insert (ix, obj); } @@ -1686,7 +1686,7 @@ vec::safe_insert (unsigned inline void vec::ordered_remove (unsigned ix) { - vec_->ordered_remove (ix); + m_vec->ordered_remove (ix); } @@ -1697,7 +1697,7 @@ vec::ordered_remove (unsig inline void vec::unordered_remove (unsigned ix) { - vec_->unordered_remove (ix); + m_vec->unordered_remove (ix); } @@ -1708,7 +1708,7 @@ vec::unordered_remove (uns inline void vec::block_remove (unsigned ix, unsigned len) { - vec_->block_remove (ix, len); + m_vec->block_remove (ix, len); } @@ -1719,8 +1719,8 @@ vec::block_remove (unsigne inline void vec::qsort (int (*cmp) (const void *, const void *)) { - if (vec_) - vec_->qsort (cmp); + if (m_vec) + m_vec->qsort (cmp); } @@ -1734,11 +1734,11 @@ vec::qsort (int (*cmp) (co vec::lower_bound (T obj, bool (*lessthan)(const T &, const T &)) const { - return vec_ ? vec_->lower_bound (obj, lessthan) : 0; + return m_vec ? m_vec->lower_bound (obj, lessthan) : 0; } #if (GCC_VERSION >= 3000) -# pragma GCC poison vec_ vecpfx_ vecdata_ +# pragma GCC poison m_vec m_vecpfx m_vecdata #endif #endif // GCC_VEC_H