[lldb][nfc] Use delegating ctor for ExecutionContext (#151987)

The ctor that takes a reference to ExecutionContextRef can be
implemented in terms of the ctor that takes a pointer to that object,
removing code duplication.
This commit is contained in:
Felipe de Azevedo Piovezan 2025-08-04 09:43:21 -07:00 committed by GitHub
parent 7b208e04b2
commit 80bd72b9b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 14 deletions

View File

@ -318,7 +318,9 @@ public:
// These two variants take in a locker, and grab the target, lock the API
// mutex into locker, then fill in the rest of the shared pointers.
ExecutionContext(const ExecutionContextRef &exe_ctx_ref,
std::unique_lock<std::recursive_mutex> &locker);
std::unique_lock<std::recursive_mutex> &locker)
: ExecutionContext(&exe_ctx_ref, locker) {}
ExecutionContext(const ExecutionContextRef *exe_ctx_ref,
std::unique_lock<std::recursive_mutex> &locker);
// Create execution contexts from execution context scopes

View File

@ -140,19 +140,6 @@ ExecutionContext::ExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr,
}
}
ExecutionContext::ExecutionContext(const ExecutionContextRef &exe_ctx_ref,
std::unique_lock<std::recursive_mutex> &lock)
: m_target_sp(exe_ctx_ref.GetTargetSP()), m_process_sp(), m_thread_sp(),
m_frame_sp() {
if (m_target_sp) {
lock = std::unique_lock<std::recursive_mutex>(m_target_sp->GetAPIMutex());
m_process_sp = exe_ctx_ref.GetProcessSP();
m_thread_sp = exe_ctx_ref.GetThreadSP();
m_frame_sp = exe_ctx_ref.GetFrameSP();
}
}
ExecutionContext::ExecutionContext(ExecutionContextScope *exe_scope_ptr)
: m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
if (exe_scope_ptr)