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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
lldb/source/Interpreter/CommandObject.cpp | ||
---|---|---|
281 | Should we reset the context here as well? Maybe it's wroth wrapping this in a simple RAII class that unsets the context on destruction. |
Thanks very much Jonas for pointing out my carelessness! And with your RAII idea, I think we can use the smart pointer to simulate the defer thing.
LLVM actually has it's own cod for doing this (IIUC, it has the benefit of being easier to migrate to an upcoming standard library utility class with the same purpose).
Beside that this LGTM.
lldb/source/Interpreter/CommandObject.cpp | ||
---|---|---|
273 | The LLVM way of doing this is auto reset_ctx = llvm::make_scope_exit([this]() { Cleanup(); }); (from the #include "llvm/ADT/ScopeExit.h" header). |
The LLVM way of doing this is auto reset_ctx = llvm::make_scope_exit([this]() { Cleanup(); }); (from the #include "llvm/ADT/ScopeExit.h" header).