From cf6a4bbc42c7e54bf6e251206134b207e757b604 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 25 Jul 2025 15:55:21 -0700 Subject: [lldb] Use std::make_shared where possible (NFC) (#150714) This is a continuation of 68fd102, which did the same thing but only for StopInfo. Using make_shared is both safer and more efficient: - With make_shared, the object and the control block are allocated together, which is more efficient. - With make_shared, the enable_shared_from_this base class is properly linked to the control block before the constructor finishes, so shared_from_this() will be safe to use (though still not recommended during construction). --- .../Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 0c864dc..457182a 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1496,7 +1496,7 @@ lldb::ValueObjectListSP ScriptInterpreterPythonImpl::GetRecognizedArguments( } if (py_return.get()) { PythonList result_list(PyRefType::Borrowed, py_return.get()); - ValueObjectListSP result = ValueObjectListSP(new ValueObjectList()); + ValueObjectListSP result = std::make_shared(); for (size_t i = 0; i < result_list.GetSize(); i++) { PyObject *item = result_list.GetItemAtIndex(i).get(); lldb::SBValue *sb_value_ptr = @@ -3047,7 +3047,7 @@ bool ScriptInterpreterPythonImpl::SetOptionValueForCommandObject( lldb::ExecutionContextRefSP exe_ctx_ref_sp; if (exe_ctx) - exe_ctx_ref_sp.reset(new ExecutionContextRef(exe_ctx)); + exe_ctx_ref_sp = std::make_shared(exe_ctx); PythonObject ctx_ref_obj = SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp); bool py_return = unwrapOrSetPythonException(As( -- cgit v1.1