summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ScriptInterpreter/Python
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp2
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h30
2 files changed, 5 insertions, 27 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index 3ac404b532d..1fb9355b9ee 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -410,7 +410,7 @@ void PythonString::SetString(llvm::StringRef string) {
llvm::consumeError(s.takeError());
Reset();
} else {
- PythonObject::Reset(std::move(s.get()));
+ *this = std::move(s.get());
}
}
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
index 7f460234ffb..5823f740a53 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -182,7 +182,8 @@ public:
Reset(type, py_obj);
}
- PythonObject(const PythonObject &rhs) : m_py_obj(nullptr) { Reset(rhs); }
+ PythonObject(const PythonObject &rhs)
+ : PythonObject(PyRefType::Borrowed, rhs.m_py_obj) {}
PythonObject(PythonObject &&rhs) {
m_py_obj = rhs.m_py_obj;
@@ -197,19 +198,6 @@ public:
m_py_obj = nullptr;
}
- void Reset(const PythonObject &rhs) {
- if (!rhs.IsValid())
- Reset();
- else
- Reset(PyRefType::Borrowed, rhs.m_py_obj);
- }
-
- // PythonObject is implicitly convertible to PyObject *, which will call the
- // wrong overload. We want to explicitly disallow this, since a PyObject
- // *always* owns its reference. Therefore the overload which takes a
- // PyRefType doesn't make sense, and the copy constructor should be used.
- void Reset(PyRefType type, const PythonObject &ref) = delete;
-
void Reset(PyRefType type, PyObject *py_obj) {
if (py_obj == m_py_obj)
return;
@@ -244,19 +232,9 @@ public:
return result;
}
- PythonObject &operator=(const PythonObject &other) {
- Reset(PyRefType::Borrowed, other.get());
- return *this;
- }
-
- void Reset(PythonObject &&other) {
+ PythonObject &operator=(PythonObject other) {
Reset();
- m_py_obj = other.m_py_obj;
- other.m_py_obj = nullptr;
- }
-
- PythonObject &operator=(PythonObject &&other) {
- Reset(std::move(other));
+ m_py_obj = std::exchange(other.m_py_obj, nullptr);
return *this;
}
OpenPOWER on IntegriCloud