This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH: Use VAR_P instead of direct TREE_CODE (t) == VAR_DECL
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Gabriel Dos Reis <gdr at axiomatics dot org>, Paolo Carlini <paolo dot carlini at oracle dot com>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 2 Apr 2013 04:30:25 -0500
- Subject: Re: C++ PATCH: Use VAR_P instead of direct TREE_CODE (t) == VAR_DECL
- References: <87mwtmkxil dot fsf at euclid dot axiomatics dot org> <5155C755 dot 1000107 at oracle dot com> <87a9pmw34o dot fsf at euclid dot axiomatics dot org> <CAFiYyc1vncpO-Ji-7VmLrvQGi5ws+eo+3xz2946moR=-gWTA_Q at mail dot gmail dot com>
On Tue, Apr 2, 2013 at 4:26 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Fri, Mar 29, 2013 at 6:02 PM, Gabriel Dos Reis <gdr@axiomatics.org> wrote:
>> Paolo Carlini <paolo.carlini@oracle.com> writes:
>>
>> | Hi,
>> |
>> | On 03/29/2013 04:59 PM, Gabriel Dos Reis wrote:
>> | > This patch introduces the predicate VAR_P and use it in place of direct
>> | >
>> | > TREE_CODE (t) == VAR_DECL
>> | >
>> | > It improves readability and makes predicates easier to follow.
>> | > Tested on an x86_64-suse-linux. Applying to trunk.
>> | Thanks.
>> |
>> | Do you think it would also make sense to consistently use in C++
>> | front-end TYPE_PTR_P instead of TREE_CODE (t) == POINTER_TYPE? It's
>> | something I noticed a while ago when I cleaned-up predicated related
>> | to pointers and occurred to me again now that you are doing some of
>> | this kind of work. If you like I can do this bit.
>> |
>> | Thanks,
>> | Paolo.
>>
>> Yes, you are absolutely right. Thanks for volunteering.
>
> Sorry for chiming in late - but VAR_P loses the fact that we are checking
> for a decl ... VAR_DECL_P would be more like following existing practice
> (otherwise we can shorten VAR_OR_FUNCTION_DECL_P to
> VAR_OR_FUNCTION_P for example). As for further cleanups we seem
> to have a few IS_... macros as well (one even IS_..._P).
>
> Richard.
If we are checking for a VAR, we necessarily checking for a VAR decl..
The purpose of the macro is make the predicates more readable.
I would not mind having VAR_OR_FUNCTION_P instead.
Yes, we should get rid of the IS_.
-- Gaby