================
@@ -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
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to