https://github.com/oontvoo created 
https://github.com/llvm/llvm-project/pull/133785

Details: The ScopedDiscpatcher's dtor may reference these fields so we need the 
fields' dtor to be be invoked *after* the dispatcher's.

>From 55d20dc85389bdeacf806b18ff132030e2626d9a Mon Sep 17 00:00:00 2001
From: Vy Nguyen <v...@google.com>
Date: Mon, 31 Mar 2025 15:47:06 -0400
Subject: [PATCH] [LLDB][NFC]Move fields that might be referenced in scope-exit
 to beginning of functions so they are still valid when referenced.

---
 lldb/source/Interpreter/CommandInterpreter.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 8e70922b9bb8d..7fbdf7fe70223 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1886,6 +1886,13 @@ bool CommandInterpreter::HandleCommand(const char 
*command_line,
                                        LazyBool lazy_add_to_history,
                                        CommandReturnObject &result,
                                        bool force_repeat_command) {
+  // These are assigned later in the function but they must be declared before
+  // the ScopedDispatcher object because we need their destructions to occur
+  // after the dispatcher's dtor call, which may reference them.
+  // TODO: This function could be refactored?
+  std::string parsed_command_args;
+  CommandObject *cmd_obj = nullptr;
+
   telemetry::ScopedDispatcher<telemetry::CommandInfo> helper(&m_debugger);
   const bool detailed_command_telemetry =
       telemetry::TelemetryManager::GetInstance()
@@ -1896,8 +1903,6 @@ bool CommandInterpreter::HandleCommand(const char 
*command_line,
   std::string command_string(command_line);
   std::string original_command_string(command_string);
   std::string real_original_command_string(command_string);
-  std::string parsed_command_args;
-  CommandObject *cmd_obj = nullptr;
 
   helper.DispatchNow([&](lldb_private::telemetry::CommandInfo *info) {
     info->command_id = command_id;

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to