Author: Med Ismail Bennani Date: 2022-11-19T13:24:47-08:00 New Revision: 41f3e6b74df173198c67f46f223b9815334d42a2
URL: https://github.com/llvm/llvm-project/commit/41f3e6b74df173198c67f46f223b9815334d42a2 DIFF: https://github.com/llvm/llvm-project/commit/41f3e6b74df173198c67f46f223b9815334d42a2.diff LOG: [lldb/Plugins] Fix build failure with GCC in ScriptedPythonInterface::Dispatch This patch should fix the build failures following 7e01924 when building with GCC. These failures were mostly caused by GCC's poor support of C++ templates (namely, partial template specialization). To work around that problem, this patch makes use of overloading and get rid of the templated structs and specialized structs. Signed-off-by: Med Ismail Bennani <medismail.benn...@gmail.com> Added: Modified: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h Removed: ################################################################################ diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h index ac1fe0955c370..268430f288f28 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h @@ -101,36 +101,27 @@ class ScriptedPythonInterface : virtual public ScriptedInterface { Status GetStatusFromMethod(llvm::StringRef method_name); - template <typename T> struct transformation { using type = T; }; - template <typename T, typename U> struct reverse_transformation { - static void Apply(ScriptedPythonInterface &obj, T &original_arg, - U transformed_arg, Status &error) { - // If U is not a PythonObject, don't touch it! - return; - } - }; - - template <> struct transformation<Status> { - using type = python::PythonObject; - }; - template <typename T> struct reverse_transformation<T, python::PythonObject> { - static void Apply(ScriptedPythonInterface &obj, T &original_arg, - python::PythonObject transformed_arg, Status &error) { - original_arg = - obj.ExtractValueFromPythonObject<T>(transformed_arg, error); - } - }; - - template <typename T> typename transformation<T>::type Transform(T object) { + template <typename T> T Transform(T object) { // No Transformation for generic usage return {object}; } - template <> typename transformation<Status>::type Transform(Status arg) { - // Call SWIG Wrapper function + python::PythonObject Transform(Status arg) { return python::ToSWIGWrapper(arg); } + template <typename T, typename U> + void ReverseTransform(T &original_arg, U transformed_arg, Status &error) { + // If U is not a PythonObject, don't touch it! + return; + } + + template <typename T> + void ReverseTransform(T &original_arg, python::PythonObject transformed_arg, + Status &error) { + original_arg = ExtractValueFromPythonObject<T>(transformed_arg, error); + } + template <std::size_t... I, typename... Args> auto TransformTuple(const std::tuple<Args...> &args, std::index_sequence<I...>) { @@ -146,8 +137,7 @@ class ScriptedPythonInterface : virtual public ScriptedInterface { template <typename T, typename U> void TransformBack(T &original_arg, U transformed_arg, Status &error) { - reverse_transformation<T, U>::Apply(*this, original_arg, transformed_arg, - error); + ReverseTransform(original_arg, transformed_arg, error); } template <std::size_t... I, typename... Ts, typename... Us> _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits