[llvm] [Offload] Define `_NUM_VARIANTS` macros for generated enumerations (PR #147314)

Ross Brunton via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 8 01:57:52 PDT 2025


================
@@ -151,6 +151,12 @@ static void ProcessEnum(const EnumRec &Enum, raw_ostream &OS) {
                 Enum.getEnumValNamePrefix());
 
   OS << formatv("} {0};\n", Enum.getName());
+
+  // Add field for the number of variants
+  OS << formatv(TAB_1
----------------
RossBrunton wrote:

We don't generate one, would that be preferred over a separate macro? The only issue I could see is that any switch statements over the enums would not be exhaustive and have to have an "unreachable" default or face warnings.

https://github.com/llvm/llvm-project/pull/147314


More information about the llvm-commits mailing list