[Lldb-commits] [lldb] [LLDB][NFC]Move fields that might be referenced in scope-exit to beginning (PR #133785)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 31 12:50:02 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Vy Nguyen (oontvoo)
<details>
<summary>Changes</summary>
Details: The ScopedDiscpatcher's dtor may reference these fields so we need the fields' dtor to be be invoked *after* the dispatcher's.
---
Full diff: https://github.com/llvm/llvm-project/pull/133785.diff
1 Files Affected:
- (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+7-2)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/133785
More information about the lldb-commits
mailing list