aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter/CommandObject.cpp
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2020-05-27 14:04:39 +0200
committerRaphael Isemann <teemperor@gmail.com>2020-05-27 14:05:17 +0200
commit18bb1f1067028fbeaf92774e640bd865c53e1ce1 (patch)
tree0e2cae9916d8df1a4b4608c9117bf5a1b3a558fb /lldb/source/Interpreter/CommandObject.cpp
parent6e1eff785892edb75948f3c0a18e01ef8fbe2619 (diff)
downloadllvm-18bb1f1067028fbeaf92774e640bd865c53e1ce1.zip
llvm-18bb1f1067028fbeaf92774e640bd865c53e1ce1.tar.gz
llvm-18bb1f1067028fbeaf92774e640bd865c53e1ce1.tar.bz2
[lldb] Fix a potential bug that may cause assert failure in CommandObject::CheckRequirements
Summary: `CommandObject::CheckRequirements` requires cleaning up `m_exe_ctx` between commands. Function `HandleOptionCompletion` returns without cleaning up `m_exe_ctx` could cause assert failure in later `CheckRequirements`. Reviewers: teemperor, JDevlieghere Reviewed By: teemperor Tags: #lldb Differential Revision: https://reviews.llvm.org/D80447
Diffstat (limited to 'lldb/source/Interpreter/CommandObject.cpp')
-rw-r--r--lldb/source/Interpreter/CommandObject.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index f1f17db..ddf1f55 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -18,6 +18,7 @@
#include "lldb/Core/Address.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Utility/ArchSpec.h"
+#include "llvm/ADT/ScopeExit.h"
// These are for the Sourcename completers.
// FIXME: Make a separate file for the completers.
@@ -269,6 +270,7 @@ void CommandObject::Cleanup() {
void CommandObject::HandleCompletion(CompletionRequest &request) {
m_exe_ctx = m_interpreter.GetExecutionContext();
+ auto reset_ctx = llvm::make_scope_exit([this]() { Cleanup(); });
// Default implementation of WantsCompletion() is !WantsRawCommandString().
// Subclasses who want raw command string but desire, for example, argument
@@ -296,8 +298,6 @@ void CommandObject::HandleCompletion(CompletionRequest &request) {
// 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,