diff options
| author | Alex Langford <alangford@apple.com> | 2023-11-10 12:47:43 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-10 12:47:43 -0800 |
| commit | 133bcacecfb70e8b1692f9c2c0a44ec640a0422a (patch) | |
| tree | cb3b64640b80edac0f2be1cc89e8ccfb37795728 /lldb/source/Plugins/Process/scripted/ScriptedThread.cpp | |
| parent | bfe08c094deb6e24e814fa46470de2700aab01ff (diff) | |
[lldb] Change interface of StructuredData::Array::GetItemAtIndexAsDictionary (#71961)
Similar to my previous patch (#71613) where I changed
`GetItemAtIndexAsString`, this patch makes the same change to
`GetItemAtIndexAsDictionary`.
`GetItemAtIndexAsDictionary` now returns a std::optional that is either
`std::nullopt` or is a valid pointer. Therefore, if the optional is
populated, we consider the pointer to always be valid (i.e. no need to
check pointer validity).
Diffstat (limited to 'lldb/source/Plugins/Process/scripted/ScriptedThread.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/scripted/ScriptedThread.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp index aa2796db15cd..88a4ca3b0389 100644 --- a/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp +++ b/lldb/source/Plugins/Process/scripted/ScriptedThread.cpp @@ -176,8 +176,9 @@ bool ScriptedThread::LoadArtificialStackFrames() { StackFrameListSP frames = GetStackFrameList(); for (size_t idx = 0; idx < arr_size; idx++) { - StructuredData::Dictionary *dict; - if (!arr_sp->GetItemAtIndexAsDictionary(idx, dict) || !dict) + std::optional<StructuredData::Dictionary *> maybe_dict = + arr_sp->GetItemAtIndexAsDictionary(idx); + if (!maybe_dict) return ScriptedInterface::ErrorWithMessage<bool>( LLVM_PRETTY_FUNCTION, llvm::Twine( @@ -185,6 +186,7 @@ bool ScriptedThread::LoadArtificialStackFrames() { llvm::Twine(idx) + llvm::Twine(") from stackframe array.")) .str(), error, LLDBLog::Thread); + StructuredData::Dictionary *dict = *maybe_dict; lldb::addr_t pc; if (!dict->GetValueForKeyAsInteger("pc", pc)) |
