Skip to content

Conversation

felipepiovezan
Copy link
Contributor

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.

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.
@llvmbot
Copy link
Member

llvmbot commented Aug 4, 2025

@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/151987.diff

2 Files Affected:

  • (modified) lldb/include/lldb/Target/ExecutionContext.h (+3-1)
  • (modified) lldb/source/Target/ExecutionContext.cpp (-13)
diff --git a/lldb/include/lldb/Target/ExecutionContext.h b/lldb/include/lldb/Target/ExecutionContext.h
index d8c233a666bb4..aebd0d5308e72 100644
--- a/lldb/include/lldb/Target/ExecutionContext.h
+++ b/lldb/include/lldb/Target/ExecutionContext.h
@@ -318,7 +318,9 @@ class ExecutionContext {
   // 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
diff --git a/lldb/source/Target/ExecutionContext.cpp b/lldb/source/Target/ExecutionContext.cpp
index b1563d9ceb71b..3f54ea55c9c81 100644
--- a/lldb/source/Target/ExecutionContext.cpp
+++ b/lldb/source/Target/ExecutionContext.cpp
@@ -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)

Copy link
Collaborator

@jimingham jimingham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@felipepiovezan felipepiovezan merged commit 80bd72b into llvm:main Aug 4, 2025
11 checks passed
@felipepiovezan felipepiovezan deleted the felipe/delegating_ctor branch August 4, 2025 16:43
felipepiovezan added a commit to felipepiovezan/llvm-project that referenced this pull request Sep 2, 2025
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.

(cherry picked from commit 80bd72b)
medismailben pushed a commit to medismailben/llvm-project that referenced this pull request Sep 5, 2025
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.

(cherry picked from commit 80bd72b)
medismailben pushed a commit to medismailben/llvm-project that referenced this pull request Sep 5, 2025
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.

(cherry picked from commit 80bd72b)
medismailben pushed a commit to medismailben/llvm-project that referenced this pull request Sep 5, 2025
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.

(cherry picked from commit 80bd72b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants