Index: lldb/source/Interpreter/CommandObject.cpp =================================================================== --- lldb/source/Interpreter/CommandObject.cpp +++ lldb/source/Interpreter/CommandObject.cpp @@ -269,6 +269,7 @@ void CommandObject::HandleCompletion(CompletionRequest &request) { m_exe_ctx = m_interpreter.GetExecutionContext(); + std::shared_ptr _(nullptr, std::bind([this] { this->Cleanup(); })); // Default implementation of WantsCompletion() is !WantsRawCommandString(). // Subclasses who want raw command string but desire, for example, argument @@ -296,8 +297,6 @@ // If we got here, the last word is not an option or an option argument. HandleArgumentCompletion(request, opt_element_vector); } - - m_exe_ctx.Clear(); } bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word,