================ @@ -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 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits