[PATCH] D107350: Add a trait to Sequence to iterate enums

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 3 11:03:52 PDT 2021


kuhar added a comment.

Thanks for looking into this, @gchatelet

> As-is, I fear it doesn't bring a lot of value, @kuhar WDYT? Any suggestions on how to make it nicer to use / safer?

Yes, the trait-based implementation is not the easiest to use like this, especially with projects using different namespaces and nested enums.

What if instead we put traits together with enum values, and have a function (customization point) to augment an enum value with its traits? Then we can have a way to opt into enum iteration even for enums that aren't declared as iterable. I made a quick proof of concept and uploaded it here: https://reviews.llvm.org/D107378.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107350



More information about the llvm-commits mailing list