By default llvm::seq would happily iterate over enums, which may be unsafe if the enum values are not continuous. This patch forces the user to declare the enum as iterable before being able to do so (with DECLARE_ITERABLE_ENUM). Similarly, we allow enums to be explicitly marked as unsafe for iteration with DECLARE_NON_ITERABLE_ENUM.
The main benefit of this approach is that these global declarations (DECLARE_ITERABLE_ENUM) appear just next to enum definitions, making easy to spot when enums are miss-labeled, e.g., after introducing new enum values.
Because it's not always possible to add these declarations next to enum definition (e.g., for enums defined in external libraries), we provide an escape hatch to allow iteration on per-callsite basis with forge_iterable_enum.
This emerged from a discussion with gchalet@ about reusing llvm's Sequence.h in lieu of https://github.com/GPUOpen-Drivers/llpc/blob/dev/lgc/interface/lgc/EnumIterator.h.