[llvm] [DirectX] Error handling improve in root signature metadata Parser (PR #149232)
Chris B via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 25 10:29:45 PDT 2025
================
@@ -26,6 +28,73 @@ class Metadata;
namespace hlsl {
namespace rootsig {
+template <typename T>
+class RootSignatureValidationError
+ : public ErrorInfo<RootSignatureValidationError<T>> {
+public:
+ static char ID;
+ std::string ParamName;
+ T Value;
+
+ RootSignatureValidationError(StringRef ParamName, T Value)
+ : ParamName(ParamName.str()), Value(Value) {}
+
+ void log(raw_ostream &OS) const override {
+ OS << "Invalid value for " << ParamName << ": " << Value;
+ }
+
+ std::error_code convertToErrorCode() const override {
+ return llvm::inconvertibleErrorCode();
+ }
+};
+
+class GenericRSMetadataError : public ErrorInfo<GenericRSMetadataError> {
+public:
+ static char ID;
+ std::string Message;
+
+ GenericRSMetadataError(Twine Message) : Message(Message.str()) {}
----------------
llvm-beanz wrote:
Why not make this take a `StringRef` and the pointer to the metadata node that the error refers to? Then the message formatting can be something like:
```
void log(raw_ostream &OS) const override {
OS << Message;
if (MD)
MD->printTree(OS);
}
https://github.com/llvm/llvm-project/pull/149232
More information about the llvm-commits
mailing list