[PATCH] D107350: Add a trait to Sequence to iterate enums
Guillaume Chatelet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 10 08:17:00 PDT 2021
gchatelet added a comment.
In D107350#2937039 <https://reviews.llvm.org/D107350#2937039>, @kuhar wrote:
>> AFAIU the proposal is about making sure that we don't iterate on an enum by mistake but in your patch it seems that calling `make_iterable_enum` bypasses this security (i.e. X86::CondCode has never been declared iterable <https://reviews.llvm.org/D107378#change-DgLEQ1SuLFJw> ). Was that intended?
>
> Yes, it was intentional. This is the 'escape hatch' that I mentioned. This is so that it's still possible to iterate over enums when the declaration is missing, for example, when we cannot modify the code where the enum comes from (think an external library), or know that only a part of enum values is iterable and don't want to declare the whole thing as safe to iterate over.
Ah I see, then maybe the name should raise a visual warning, How about `forge_iterable_enum`?
SG for the unused attribute.
I'll update this patch based on your implementation and we can iterate from here.
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