From cfca06d7963fa0909f90483b42a6d7d194d01e08 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 26 Jul 2020 19:36:28 +0000 Subject: Vendor import of llvm-project master 2e10b7a39b9, the last commit before the llvmorg-12-init tag, from which release/11.x was branched. --- .../ScriptInterpreter/Python/PythonDataObjects.h | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h index b75045b239a8..22f6c67eb7a5 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h @@ -36,7 +36,7 @@ // can never fail to assert instead, such as the creation of // PythonString from a string literal. // -// * Elimintate Reset(), and make all non-default constructors private. +// * Eliminate Reset(), and make all non-default constructors private. // Python objects should be created with Retain<> or Take<>, and they // should be assigned with operator= // @@ -90,7 +90,9 @@ public: void Serialize(llvm::json::OStream &s) const override; private: - DISALLOW_COPY_AND_ASSIGN(StructuredPythonObject); + StructuredPythonObject(const StructuredPythonObject &) = delete; + const StructuredPythonObject & + operator=(const StructuredPythonObject &) = delete; }; enum class PyObjectType { @@ -319,7 +321,6 @@ public: StructuredData::ObjectSP CreateStructuredObject() const; -public: template llvm::Expected CallMethod(const char *name, const T &... t) const { @@ -360,15 +361,12 @@ public: return !!r; } - llvm::Expected AsLongLong() { - if (!m_py_obj) - return nullDeref(); - assert(!PyErr_Occurred()); - long long r = PyLong_AsLongLong(m_py_obj); - if (PyErr_Occurred()) - return exception(); - return r; - } + llvm::Expected AsLongLong() const; + + llvm::Expected AsUnsignedLongLong() const; + + // wraps on overflow, instead of raising an error. + llvm::Expected AsModuloUnsignedLongLong() const; llvm::Expected IsInstance(const PythonObject &cls) { if (!m_py_obj || !cls.IsValid()) @@ -399,6 +397,10 @@ template <> llvm::Expected As(llvm::Expected &&obj); template <> llvm::Expected As(llvm::Expected &&obj); +template <> +llvm::Expected +As(llvm::Expected &&obj); + template <> llvm::Expected As(llvm::Expected &&obj); @@ -491,8 +493,6 @@ public: static bool Check(PyObject *py_obj); static void Convert(PyRefType &type, PyObject *&py_obj); - int64_t GetInteger() const; - void SetInteger(int64_t value); StructuredData::IntegerSP CreateStructuredInteger() const; @@ -595,7 +595,7 @@ public: // safe, returns invalid on error; static PythonModule ImportModule(llvm::StringRef name) { - std::string s = name; + std::string s = std::string(name); auto mod = Import(s.c_str()); if (!mod) { llvm::consumeError(mod.takeError()); -- cgit v1.2.3