[PATCH] D107378: Make enum iteration with seq safe by default

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 19 16:42:47 PDT 2021


dblaikie added a comment.

In D107378#3073037 <https://reviews.llvm.org/D107378#3073037>, @kuhar wrote:

> Thanks for the comments. If I understand correctly, we are converging to something like this:
>
> 1. We should keep enum iteration utilities but make them safe by default.
> 2. By default, enums shouldn't not be iterable and enum iteration should be opt-in.
>   1. @dblaikie prefers the opt-in mechanism to be plain type traits, not the original type traits / ADL / macro mechanism from this patch.
> 3. We should rely on `iota_range` for the implementation, but create a new convenience function instead of reusing `seq` and `seq_inclusive`, say `enum_seq` and `enum_seq_inclusive`.
>   1. To provide an 'escape hatch' to iterate over enums without the new trait, we can use an intentionally ugly traits/tag like `forge_iterable_enum`(`_traits`).
>
> If this sounds good to folks, I'll go ahead and prepare a new version of this patch.

Yep, sounds about right to me - maybe (1) might not need a trait or tag - could be an extra argument to the enum_seq functions that can only be spelled "force_iteration_on_noniterable_enum" or something like that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107378/new/

https://reviews.llvm.org/D107378



More information about the llvm-commits mailing list