aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
diff options
context:
space:
mode:
authorAlex Langford <alangford@apple.com>2023-11-10 12:47:43 -0800
committerGitHub <noreply@github.com>2023-11-10 12:47:43 -0800
commit133bcacecfb70e8b1692f9c2c0a44ec640a0422a (patch)
treecb3b64640b80edac0f2be1cc89e8ccfb37795728 /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
parentbfe08c094deb6e24e814fa46470de2700aab01ff (diff)
downloadllvm-133bcacecfb70e8b1692f9c2c0a44ec640a0422a.zip
llvm-133bcacecfb70e8b1692f9c2c0a44ec640a0422a.tar.gz
llvm-133bcacecfb70e8b1692f9c2c0a44ec640a0422a.tar.bz2
[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/gdb-remote/GDBRemoteCommunicationClient.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 04d98b9..2cf8c29 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2649,10 +2649,12 @@ size_t GDBRemoteCommunicationClient::QueryGDBServer(
return 0;
for (size_t i = 0, count = array->GetSize(); i < count; ++i) {
- StructuredData::Dictionary *element = nullptr;
- if (!array->GetItemAtIndexAsDictionary(i, element))
+ std::optional<StructuredData::Dictionary *> maybe_element =
+ array->GetItemAtIndexAsDictionary(i);
+ if (!maybe_element)
continue;
+ StructuredData::Dictionary *element = *maybe_element;
uint16_t port = 0;
if (StructuredData::ObjectSP port_osp =
element->GetValueForKey(llvm::StringRef("port")))