[Lldb-commits] [PATCH] D13094: LLDB-MI: Fix assignment operator in CMIUtilString

Eugene Leviant via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 24 03:32:09 PDT 2015


evgeny777 added inline comments.

================
Comment at: tools/lldb-mi/MIUtilString.cpp:41
@@ -40,3 +40,3 @@
 CMIUtilString::CMIUtilString(const char *vpData)
-    : std::string(vpData)
+    : std::string(vpData != nullptr ? vpData : "")
 {
----------------
ki.stfu wrote:
> Not sure about usefulness of these changes. The NULL usually means an error in contrast to "" which means "there is nothing to show". In your case, you can check whether it's NULL or not, and then construct an object.
> 
> Besides that, you can use operator=:
> ```
> SBValue val;
> CMIUtilString s;
> if (const char* s_cstr = val.GetSummary())
>   s = s_cstr;
> ```
As I already said, in MI both NULL and "" mean nothing to output. Regarding your proposal compare this


```
CMIUtilString s;
if (const char* ss = val.GetSummary())  {
    if ((s=ss).size()) {
    }

}
```
with this 

```
if ( (s = val.GetSummary()).size() ) {
}
```



http://reviews.llvm.org/D13094





More information about the lldb-commits mailing list