[clang] [CIR] Add the ability to detect enum argument for switch op (PR #172236)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 13 14:41:06 PST 2026


================
@@ -1282,7 +1282,7 @@ void testSwitchCoverAllCase(M m) {
     break;
   }
 }
-// CIR: cir.switch(%[[ARG:.*]] : !s32i) allEnumCasesCovered {
+// CIR: cir.switch(%[[ARG:.*]] : !s32i) allEnumCasesCovered handling_enum {
----------------
bcardosolopes wrote:

I think that we should avoid encoding a property that can always be easily queried. CIR should be capturing enum info in the type system such that we can directly know if the condition type is of a enum type without hardcoding that info. SwitchOp should have an extra method "isConditionEnum()" which can return this information by looking at the condition. Have you explored anything along those lines?

Note all cases covered has a different tradeoff: it's expensive to compute.

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


More information about the cfe-commits mailing list