[clang] [llvm] [DirectX] Fix Flags validation to prevent casting into enum (PR #161587)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 6 11:47:19 PDT 2025
https://github.com/bogner commented:
I think it would be a slightly clearer design if we have a separate `isValidRootDesciptorFlags` and `isValidDescriptorRangeFlags` in `DXContainer.h` similarly to the other `isValidX` functions in there. Then we don't need to do the awkard `to_underlying` in `SemaHLSL` where we already have a valid enum value, and the `verifyX` functions are clearly about verifying that the semantics make sense.
This will mean that in `RootSignatureMetadata.cpp` we'll need to do something slightly more verbose, like:
```c++
if (!dxbc::isValidDescriptorRangeFlags(Range.Flags) ||
!hlsl::rootsig::verifyDescriptorRangeFlag(
RSD.Version, Range.RangeType,
dxbc::DescriptorRangeFlags(Range.Flags)))
```
but this feels like an okay trade off for clarity to me. What do you think?
https://github.com/llvm/llvm-project/pull/161587
More information about the llvm-commits
mailing list