[Lldb-commits] [lldb] [lldb/API] Add setters to SBStructuredData (PR #154445)
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 21 13:56:43 PDT 2025
================
@@ -81,6 +81,40 @@ class StructuredDataImpl {
void SetObjectSP(const StructuredData::ObjectSP &obj) { m_data_sp = obj; }
+ void SetValueForKey(llvm::StringRef key,
+ const StructuredData::ObjectSP &value) {
+ if (m_data_sp) {
+ if (StructuredData::Dictionary *dict = m_data_sp->GetAsDictionary())
+ dict->AddItem(key, value);
+ return;
----------------
bulbazord wrote:
I'm not sure this does what it's supposed to. If you have a data type that's not a dictionary, this setter does nothing. But all of the other setters always override. I think you probably wanted to put the return in the same block as `dict->AddItem`, but I suggest we sidestep the explicit return entirely.
Suggestion:
```
if (!m_data_sp) {
m_data_sp = StructuredData::FromKeyValue(key, value);
} else if (StructuredData::Dictionary *dict = m_data_sp->GetAsDictionary()) {
dict->AddItem(key, value);
}
```
https://github.com/llvm/llvm-project/pull/154445
More information about the lldb-commits
mailing list