diff options
author | Michał Górny <mgorny@moritz.systems> | 2022-08-05 19:39:42 +0200 |
---|---|---|
committer | Michał Górny <mgorny@moritz.systems> | 2022-08-08 17:34:27 +0200 |
commit | 9b031d5e3a7b455308257a71116a603e76c8c679 (patch) | |
tree | 8087466908ca913f45c4267b35c688c71e1e546c /lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp | |
parent | e64025045457b7f52201fbd48b24739f64074b59 (diff) | |
download | llvm-9b031d5e3a7b455308257a71116a603e76c8c679.zip llvm-9b031d5e3a7b455308257a71116a603e76c8c679.tar.gz llvm-9b031d5e3a7b455308257a71116a603e76c8c679.tar.bz2 |
[lldb] Make Process and subclass constructors protected
Make constructors of the Process and its subclasses class protected,
to prevent accidentally constructing Process on stack when it could be
afterwards accessed via a shared_ptr (since it uses
std::enable_shared_from_this<>).
The only place where a stack allocation was used were unittests,
and fixing them via declaring an explicit public constructor
in the respective mock classes is trivial.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D131275
Diffstat (limited to 'lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp index cd2d4fe4..11692cb 100644 --- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp +++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp @@ -62,8 +62,8 @@ lldb::ProcessSP ScriptedProcess::CreateInstance(lldb::TargetSP target_sp, ScriptedProcess::ScriptedProcessInfo scripted_process_info( target_sp->GetProcessLaunchInfo()); - auto process_sp = std::make_shared<ScriptedProcess>( - target_sp, listener_sp, scripted_process_info, error); + auto process_sp = std::shared_ptr<ScriptedProcess>(new ScriptedProcess( + target_sp, listener_sp, scripted_process_info, error)); if (error.Fail() || !process_sp || !process_sp->m_script_object_sp || !process_sp->m_script_object_sp->IsValid()) { |