[llvm-branch-commits] [llvm] [DirectX] Improve error handling and validation in root signature parsing (PR #144577)

Chris B via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 11 11:42:11 PDT 2025


================
@@ -48,6 +48,71 @@ static bool reportValueError(LLVMContext *Ctx, Twine ParamName,
   return true;
 }
 
+// Template function to get formatted type string based on C++ type
+template <typename T> std::string getTypeFormatted() {
+  if constexpr (std::is_same_v<T, MDString>) {
+    return "string";
+  } else if constexpr (std::is_same_v<T, MDNode *> ||
+                       std::is_same_v<T, const MDNode *>) {
+    return "metadata";
+  } else if constexpr (std::is_same_v<T, ConstantAsMetadata *> ||
+                       std::is_same_v<T, const ConstantAsMetadata *>) {
+    return "constant";
+  } else if constexpr (std::is_same_v<T, ConstantAsMetadata>) {
+    return "constant";
+  } else if constexpr (std::is_same_v<T, ConstantInt *> ||
+                       std::is_same_v<T, const ConstantInt *>) {
+    return "constant int";
+  } else if constexpr (std::is_same_v<T, ConstantInt>) {
+    return "constant int";
+  }
+  return "unknown";
+}
+
+// Helper function to get the actual type of a metadata operand
+std::string getActualMDType(const MDNode *Node, unsigned Index) {
----------------
llvm-beanz wrote:

```suggestion
StringRef getActualMDType(const MDNode *Node, unsigned Index) {
```

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


More information about the llvm-branch-commits mailing list