This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Add null identifiers to genmatch
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: Pedro Alves <palves at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, richard dot sandiford at arm dot com
- Date: Mon, 9 Nov 2015 15:56:28 +0100
- Subject: Re: Add null identifiers to genmatch
- Authentication-results: sourceware.org; auth=none
- References: <87lhaaosh5 dot fsf at e105548-lin dot cambridge dot arm dot com> <563E0B2D dot 3080408 at redhat dot com> <563FD7F8 dot 1020503 at redhat dot com>
On Mon, Nov 9, 2015 at 12:17 AM, Jeff Law <law@redhat.com> wrote:
> On 11/07/2015 07:31 AM, Pedro Alves wrote:
>>
>> Hi Richard,
>>
>> Passerby comment below.
>>
>> On 11/07/2015 01:21 PM, Richard Sandiford wrote:
>>>
>>> -/* Lookup the identifier ID. */
>>> +/* Lookup the identifier ID. Allow "null" if ALLOW_NULL. */
>>>
>>> id_base *
>>> -get_operator (const char *id)
>>> +get_operator (const char *id, bool allow_null = false)
>>> {
>>> + if (allow_null && strcmp (id, "null") == 0)
>>> + return null_id;
>>> +
>>> id_base tem (id_base::CODE, id);
>>
>>
>> Boolean params are best avoided if possible, IMO. In this case,
>> it seems this could instead be a new wrapper function, like:
>
> This hasn't been something we've required for GCC. I've come across this
> recommendation a few times over the last several months as I continue to
> look at refactoring and best practices for codebases such as GCC.
>
> By encoding the boolean in the function's signature, it (IMHO) does make the
> code a bit easier to read, primarily because you don't have to go lookup the
> tense of the boolean). The problem is when the boolean is telling us some
> property an argument, but there's more than one argument and other similar
> situations.
>
> I wonder if the real benefit is in the refactoring necessary to do things in
> this way without a ton of code duplication.
I think the patch is ok as-is.
Thus ok.
Thanks,
Richard.
> Jeff
>
>