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

Ilia K via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 23 23:19:57 PDT 2015


ki.stfu requested changes to this revision.
ki.stfu added a comment.
This revision now requires changes to proceed.

Your fix in assign operator looks good. Others go out of scope of this CL, so please revert them.


================
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 : "")
 {
----------------
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;
```

================
Comment at: tools/lldb-mi/MIUtilString.cpp:45-56
@@ -44,14 +44,14 @@
 
 //++ ------------------------------------------------------------------------------------
 // Details: CMIUtilString constructor.
 // Type:    Method.
 // Args:    vpData  - Pointer to UTF8 text data.
 // Return:  None.
 // Throws:  None.
 //--
 CMIUtilString::CMIUtilString(const char *const *vpData)
-    : std::string((const char *)vpData)
+    : std::string(vpData != nullptr ? (const char *)vpData : "")
 {
 }
 
 //++ ------------------------------------------------------------------------------------
----------------
Is it really used somewhere?


http://reviews.llvm.org/D13094





More information about the lldb-commits mailing list