================ @@ -325,25 +325,19 @@ Error MetadataParser::parseDescriptorRange(mcdxbc::DescriptorTable &Table, if (RangeDescriptorNode->getNumOperands() != 6) return make_error<InvalidRSMetadataFormat>("Descriptor Range"); - dxbc::RTS0::v2::DescriptorRange Range; + mcdxbc::DescriptorRange Range; std::optional<StringRef> ElementText = extractMdStringValue(RangeDescriptorNode, 0); if (!ElementText.has_value()) return make_error<InvalidRSMetadataFormat>("Descriptor Range"); - Range.RangeType = - StringSwitch<uint32_t>(*ElementText) - .Case("CBV", to_underlying(dxbc::DescriptorRangeType::CBV)) - .Case("SRV", to_underlying(dxbc::DescriptorRangeType::SRV)) - .Case("UAV", to_underlying(dxbc::DescriptorRangeType::UAV)) - .Case("Sampler", to_underlying(dxbc::DescriptorRangeType::Sampler)) - .Default(~0U); - - if (Range.RangeType == ~0U) - return make_error<GenericRSMetadataError>("Invalid Descriptor Range type.", - RangeDescriptorNode); + Range.RangeType = StringSwitch<dxbc::DescriptorRangeType>(*ElementText) + .Case("CBV", dxbc::DescriptorRangeType::CBV) + .Case("SRV", dxbc::DescriptorRangeType::SRV) + .Case("UAV", dxbc::DescriptorRangeType::UAV) + .Case("Sampler", dxbc::DescriptorRangeType::Sampler); ---------------- bogner wrote:
I don't think we can use StringSwitch here (and I don't think we should remove the test for an invalid descriptor range type). We'll just need to do an if/else chain over the valid strings and error if we hit something invalid. https://github.com/llvm/llvm-project/pull/154629 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits