[llvm] [DirectX] Error handling improve in root signature metadata Parser (PR #149232)
Chris B via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 28 11:47:56 PDT 2025
================
@@ -182,16 +176,15 @@ MDNode *MetadataBuilder::BuildDescriptorTableClause(
const DescriptorTableClause &Clause) {
IRBuilder<> Builder(Ctx);
std::optional<StringRef> ResName =
- getResourceName(dxil::ResourceClass(llvm::to_underlying(Clause.Type)));
+ getResourceName(dxil::ResourceClass(to_underlying(Clause.Type)));
----------------
llvm-beanz wrote:
Since everywhere this function is called we have an assert that it returned a value, it seems like we probably shouldn't have it returning an optional and should instead have an `llvm_unreachable` at the end of the function.
Also, pretty sure this function doesn't need to exist at all, you should be able to just use the Scoped Printer like:
```c++
std::string Str = enumToString(Clause.Type, ResourceClassNames)
```
Note, you also don't need to be casting the Clause type to an int and back, it _is_ a `dxil::ResourceClass` (see: https://github.com/llvm/llvm-project/blob/5846381133aa001496833310aa26d52a132b6b95/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h#L85).
cc @inbelic
We should probably not have multiple different definitions of the resource class names EnumEntry mapping, but we can fix that in a subsequent PR.
https://github.com/llvm/llvm-project/pull/149232
More information about the llvm-commits
mailing list