diff options
| author | Adrian Prantl <aprantl@apple.com> | 2024-08-27 10:59:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-27 10:59:31 -0700 |
| commit | 0642cd768b80665585c8500bed2933a3b99123dc (patch) | |
| tree | a412a5eafff54ef9a7cb884e01907a4f521f5140 /lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp | |
| parent | acb33a0c9bc902dc1aef703c02b8fd3a1132cb14 (diff) | |
[lldb] Turn lldb_private::Status into a value type. (#106163)
This patch removes all of the Set.* methods from Status.
This cleanup is part of a series of patches that make it harder use the
anti-pattern of keeping a long-lives Status object around and updating
it while dropping any errors it contains on the floor.
This patch is largely NFC, the more interesting next steps this enables
is to:
1. remove Status.Clear()
2. assert that Status::operator=() never overwrites an error
3. remove Status::operator=()
Note that step (2) will bring 90% of the benefits for users, and step
(3) will dramatically clean up the error handling code in various
places. In the end my goal is to convert all APIs that are of the form
` ResultTy DoFoo(Status& error)
`
to
` llvm::Expected<ResultTy> DoFoo()
`
How to read this patch?
The interesting changes are in Status.h and Status.cpp, all other
changes are mostly
` perl -pi -e 's/\.SetErrorString/ = Status::FromErrorString/g' $(git
grep -l SetErrorString lldb/source)
`
plus the occasional manual cleanup.
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp')
| -rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp index f50bc61279d0..ea74a500518e 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp @@ -219,8 +219,9 @@ bool ScriptInterpreterLua::LoadScriptingModule( FileSpec extra_search_dir) { if (llvm::Error e = m_lua->LoadModule(filename)) { - error.SetErrorStringWithFormatv("lua failed to import '{0}': {1}\n", - filename, llvm::toString(std::move(e))); + error = Status::FromErrorStringWithFormatv( + "lua failed to import '{0}': {1}\n", filename, + llvm::toString(std::move(e))); return false; } return true; |
