[PATCH 1/8] gdbsupport: Provide global operators |=, &=, and ^= for enum bit flags
Pedro Alves
pedro@palves.net
Fri Aug 21 14:49:15 GMT 2020
On 8/17/20 11:40 AM, Andrew Burgess wrote:
>
> 3. Instead of writing 'enum some_flag', a developer might just write
> 'some_flag'.
I suspect you meant 'some_flags' in the latter case.
> In this case they still require the changes from my
> patch if they ever want to use operator|=. I think spotting the
> missing 's' is much harder during review,
I'd argue that that's an issue of naming. If people thing it's a
problem, we can use a more distinct name for the raw enums.
Some cases use enum foo_flag_value / foo_flags, which seems reasonable
to me.
> so it's easy for uses of
> 'some_flag' to creep into the code base, then a future developer
> wanting to use 'operator|=' will need to fix up the 'some_flag' to
> 'some_flags' miss-match. Though it's easy to argue that the first
> developer made a mistake, and we frequently have to fix the mistakes
> of those going before, in this case we don't have to, so why force
> the matter?
>
> I guess my argument would be, lets commit. We should either remove
> the existing global operators from enum-flags.h, fix up the fall out,
> and so make it much harder to developers to use the 'some_flag'
> version (so forcing the use of 'some_flags'), or make the change I
> propose which allows the full range of operators while loosing non of
> the protection that already exists.
This (again) reminded me of my enum-flags.h rewrite that I never
managed to commit...
I spent time around it yesterday/today, and posted it here:
https://sourceware.org/pipermail/gdb-patches/2020-August/171392.html
Thanks,
Pedro Alves
More information about the Gdb-patches
mailing list