[Lldb-commits] [lldb] 5f6f33d - [lldb/Plugins] Move member template specialization out of class

Shafik Yaghmour via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 7 08:55:14 PDT 2021


This may actually be a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282>

Not much we can do now but worth knowing in case it is fixed.

> On Sep 3, 2021, at 3:19 PM, Med Ismail Bennani via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> 
> Author: Med Ismail Bennani
> Date: 2021-09-03T22:18:55Z
> New Revision: 5f6f33da9ee6cbaef5f10b4a7be34a91d5185b2b
> 
> URL: https://github.com/llvm/llvm-project/commit/5f6f33da9ee6cbaef5f10b4a7be34a91d5185b2b
> DIFF: https://github.com/llvm/llvm-project/commit/5f6f33da9ee6cbaef5f10b4a7be34a91d5185b2b.diff
> 
> LOG: [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 <medismail.bennani at gmail.com>
> 
> Added: 
> 
> 
> Modified: 
>    lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
>    lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
> 
> Removed: 
> 
> 
> 
> ################################################################################
> diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
> index 097cbbdb6fc7e..a38cb104c0c63 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<Status>(
> +    python::PythonObject &p, Status &error) {
> +  if (lldb::SBError *sb_error = reinterpret_cast<lldb::SBError *>(
> +          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<lldb::DataExtractorSP>(
> +    python::PythonObject &p, Status &error) {
> +  lldb::SBData *sb_data = reinterpret_cast<lldb::SBData *>(
> +      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
> 
> diff  --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
> index 85ec167e1463f..bac4efbe76d8d 100644
> --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
> +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
> @@ -33,33 +33,6 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
>     return p.CreateStructuredObject();
>   }
> 
> -  template <>
> -  Status ExtractValueFromPythonObject<Status>(python::PythonObject &p,
> -                                              Status &error) {
> -    if (lldb::SBError *sb_error = reinterpret_cast<lldb::SBError *>(
> -            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
> -  ExtractValueFromPythonObject<lldb::DataExtractorSP>(python::PythonObject &p,
> -                                                      Status &error) {
> -    lldb::SBData *sb_data = reinterpret_cast<lldb::SBData *>(
> -        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);
> -  }
> -
>   template <typename T = StructuredData::ObjectSP, typename... Args>
>   T Dispatch(llvm::StringRef method_name, Status &error, Args... args) {
>     using namespace python;
> @@ -149,6 +122,16 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
>   // The lifetime is managed by the ScriptInterpreter
>   ScriptInterpreterPythonImpl &m_interpreter;
> };
> +
> +template <>
> +Status ScriptedPythonInterface::ExtractValueFromPythonObject<Status>(
> +    python::PythonObject &p, Status &error);
> +
> +template <>
> +lldb::DataExtractorSP
> +ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DataExtractorSP>(
> +    python::PythonObject &p, Status &error);
> +
> } // namespace lldb_private
> 
> #endif // LLDB_ENABLE_PYTHON
> 
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210907/72acd153/attachment.html>


More information about the lldb-commits mailing list