From 5f6f33da9ee6cbaef5f10b4a7be34a91d5185b2b Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Fri, 3 Sep 2021 22:03:06 +0000 Subject: [lldb/Plugins] Move member template specialization out of class This patch should fix the build failure that surfaced when build llvm with GCC: https://lab.llvm.org/staging/#/builders/16/builds/10450 GCC complained that I explicitely specialized `ScriptedPythonInterface::ExtractValueFromPythonObject` in a in non-namespace scope, which is tolerated by Clang. To solve this issue, the specialization were declared out of the class and implemented in the source file. Signed-off-by: Med Ismail Bennani --- .../Python/ScriptedPythonInterface.cpp | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp index 097cbbd..a38cb10 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp @@ -35,4 +35,31 @@ ScriptedPythonInterface::GetStatusFromMethod(llvm::StringRef method_name) { return error; } +template <> +Status ScriptedPythonInterface::ExtractValueFromPythonObject( + python::PythonObject &p, Status &error) { + if (lldb::SBError *sb_error = reinterpret_cast( + LLDBSWIGPython_CastPyObjectToSBError(p.get()))) + error = m_interpreter.GetStatusFromSBError(*sb_error); + else + error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status."); + + return error; +} + +template <> +lldb::DataExtractorSP +ScriptedPythonInterface::ExtractValueFromPythonObject( + python::PythonObject &p, Status &error) { + lldb::SBData *sb_data = reinterpret_cast( + LLDBSWIGPython_CastPyObjectToSBData(p.get())); + + if (!sb_data) { + error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status."); + return nullptr; + } + + return m_interpreter.GetDataExtractorFromSBData(*sb_data); +} + #endif -- cgit v1.1