This revision was automatically updated to reflect the committed changes.
Closed by commit rL248566: Allow to construct CMIUtilString using std::string 
directly + cleanup… (authored by ki.stfu).

Changed prior to commit:
  http://reviews.llvm.org/D13158?vs=35703&id=35708#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13158

Files:
  lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp
  lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp
  lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.cpp
  lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.cpp
  lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
  lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp
  lldb/trunk/tools/lldb-mi/MICmdInterpreter.cpp
  lldb/trunk/tools/lldb-mi/MICmnLLDBDebugger.cpp
  lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
  lldb/trunk/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
  lldb/trunk/tools/lldb-mi/MIDriver.cpp
  lldb/trunk/tools/lldb-mi/MIUtilString.cpp
  lldb/trunk/tools/lldb-mi/MIUtilString.h

Index: lldb/trunk/tools/lldb-mi/MIUtilString.h
===================================================================
--- lldb/trunk/tools/lldb-mi/MIUtilString.h
+++ lldb/trunk/tools/lldb-mi/MIUtilString.h
@@ -43,8 +43,7 @@
   public:
     /* ctor */ CMIUtilString();
     /* ctor */ CMIUtilString(const char *vpData);
-    /* ctor */ CMIUtilString(const char *const *vpData);
-    /* ctor */ CMIUtilString(const char *vpData, size_t nLen);
+    /* ctor */ CMIUtilString(const std::string& vrStr);
     //
     bool ExtractNumber(MIint64 &vwrNumber) const;
     CMIUtilString FindAndReplace(const CMIUtilString &vFind, const CMIUtilString &vReplaceWith) const;
Index: lldb/trunk/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
@@ -505,7 +505,7 @@
         addr += sizeof(ch);
     }
 
-    return result.c_str();
+    return result;
 }
 
 //++ ------------------------------------------------------------------------------------
Index: lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp
@@ -130,7 +130,7 @@
     }
 
     const size_t nPosEnd = nLen + nExtraSpace;
-    m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, "").c_str();
+    m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, "");
     m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
 
     return MIstatus::success;
Index: lldb/trunk/tools/lldb-mi/MIDriver.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MIDriver.cpp
+++ lldb/trunk/tools/lldb-mi/MIDriver.cpp
@@ -893,7 +893,7 @@
    const std::string vToken(vTextLine.begin(), vTextLine.begin() + nCommandOffset);
    // 001target create "/path/to/file"
    //    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- CLI command
-   const CMIUtilString vCliCommand(std::string(vTextLine, nCommandOffset).c_str());
+   const CMIUtilString vCliCommand(std::string(vTextLine, nCommandOffset));
 
    // 5. Escape special characters and embed the command in a string
    // Result: it looks like -- target create \"/path/to/file\".
Index: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugger.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugger.cpp
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugger.cpp
@@ -585,7 +585,7 @@
     while (it != m_mapIdToEventMask.end())
     {
         const CMIUtilString &rId((*it).first);
-        if (rId.find(vBroadcasterClass.c_str()) != std::string::npos)
+        if (rId.find(vBroadcasterClass) != std::string::npos)
         {
             const MIuint clientsMask = (*it).second;
             mask |= clientsMask;
@@ -678,9 +678,7 @@
         return MIstatus::failure;
     }
 
-    CMIUtilString strId(vBroadcasterClass.c_str());
-    strId += vClientName;
-
+    const CMIUtilString strId(vBroadcasterClass + vClientName);
     const MapIdToEventMask_t::const_iterator it = m_mapIdToEventMask.find(strId);
     if (it != m_mapIdToEventMask.end())
     {
Index: lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.cpp
@@ -115,6 +115,6 @@
 bool
 CMICmdArgValOptionShort::ArgNameMatch(const CMIUtilString &vrTxt) const
 {
-    const CMIUtilString strArg = vrTxt.substr(1).c_str();
+    const CMIUtilString strArg = vrTxt.substr(1);
     return (strArg == GetName());
 }
Index: lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.cpp
@@ -121,7 +121,7 @@
     if (nPos != 0)
         return false;
 
-    const CMIUtilString strNum = vrTxt.substr(1).c_str();
+    const CMIUtilString strNum = vrTxt.substr(1);
     if (!strNum.IsNumber())
         return false;
 
@@ -139,7 +139,7 @@
 bool
 CMICmdArgValThreadGrp::ExtractNumber(const CMIUtilString &vrTxt)
 {
-    const CMIUtilString strNum = vrTxt.substr(1).c_str();
+    const CMIUtilString strNum = vrTxt.substr(1);
     MIint64 nNumber = 0;
     bool bOk = strNum.ExtractNumber(nNumber);
     if (bOk)
Index: lldb/trunk/tools/lldb-mi/MIUtilString.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MIUtilString.cpp
+++ lldb/trunk/tools/lldb-mi/MIUtilString.cpp
@@ -45,25 +45,12 @@
 //++ ------------------------------------------------------------------------------------
 // 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)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: CMIUtilString constructor.
-// Type:    Method.
-// Args:    vpData  - Pointer to UTF8 text data.
-//          nLen    - Length of string.
+// Args:    vpStr  - Text data.
 // Return:  None.
 // Throws:  None.
 //--
-CMIUtilString::CMIUtilString(const char *vpData, size_t nLen)
-    : std::string(vpData, nLen)
+CMIUtilString::CMIUtilString(const std::string& vrStr)
+    : std::string(vrStr)
 {
 }
 
@@ -96,11 +83,7 @@
 //--
 CMIUtilString &CMIUtilString::operator=(const std::string &vrRhs)
 {
-    if (*this == vrRhs)
-        return *this;
-
     assign(vrRhs);
-
     return *this;
 }
 
@@ -243,7 +226,7 @@
         // Extract string between delimiters
         const size_t nSectionLen(nNextDelimiterPos - nSectionPos);
         const std::string strSection(substr(nSectionPos, nSectionLen));
-        vwVecSplits.push_back(strSection.c_str());
+        vwVecSplits.push_back(strSection);
 
         // Next
         nOffset = nNextDelimiterPos + 1;
@@ -299,7 +282,7 @@
         // Extract string between delimiters
         const size_t nSectionLen(nNextDelimiterPos - nSectionPos);
         const std::string strSection(substr(nSectionPos, nSectionLen));
-        vwVecSplits.push_back(strSection.c_str());
+        vwVecSplits.push_back(strSection);
 
         // Next
         nOffset = nNextDelimiterPos + 1;
@@ -337,7 +320,7 @@
     if (nPos == std::string::npos)
         return *this;
 
-    const CMIUtilString strNew(substr(0, nPos).c_str());
+    const CMIUtilString strNew(substr(0, nPos));
 
     return strNew;
 }
@@ -542,12 +525,12 @@
     const size_t nPos = find_last_not_of(pWhiteSpace);
     if (nPos != std::string::npos)
     {
-        strNew = substr(0, nPos + 1).c_str();
+        strNew = substr(0, nPos + 1);
     }
     const size_t nPos2 = strNew.find_first_not_of(pWhiteSpace);
     if (nPos2 != std::string::npos)
     {
-        strNew = strNew.substr(nPos2).c_str();
+        strNew = strNew.substr(nPos2);
     }
 
     return strNew;
@@ -568,7 +551,7 @@
     if (nLen > 1)
     {
         if ((strNew[0] == vChar) && (strNew[nLen - 1] == vChar))
-            strNew = strNew.substr(1, nLen - 2).c_str();
+            strNew = strNew.substr(1, nLen - 2);
     }
 
     return strNew;
Index: lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp
@@ -179,7 +179,7 @@
 
     if (rStrExpression[0] == '$')
     {
-        const CMIUtilString rStrRegister(rStrExpression.substr(1).c_str());
+        const CMIUtilString rStrRegister(rStrExpression.substr(1));
         value = frame.FindRegister(rStrRegister.c_str());
     }
     else
Index: lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp
@@ -261,7 +261,7 @@
     if (vrTxt.length() < 3)
         return false;
 
-    const CMIUtilString strArg = vrTxt.substr(2).c_str();
+    const CMIUtilString strArg = vrTxt.substr(2);
     if (strArg.IsNumber())
         return false;
 
@@ -293,7 +293,7 @@
 bool
 CMICmdArgValOptionLong::ArgNameMatch(const CMIUtilString &vrTxt) const
 {
-    const CMIUtilString strArg = vrTxt.substr(2).c_str();
+    const CMIUtilString strArg = vrTxt.substr(2);
     return (strArg == GetName());
 }
 
Index: lldb/trunk/tools/lldb-mi/MICmdInterpreter.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmdInterpreter.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdInterpreter.cpp
@@ -160,10 +160,10 @@
     if (MiHasCmdTokenPresent(vTextLine))
     {
         const std::string strNum = vTextLine.substr(0, nPos);
-        if (!CMIUtilString(strNum.c_str()).IsNumber())
+        if (!CMIUtilString(strNum).IsNumber())
             return false;
 
-        m_miCmdData.strMiCmdToken = strNum.c_str();
+        m_miCmdData.strMiCmdToken = strNum;
     }
 
     m_miCmdData.bMIOldStyle = false;
@@ -256,20 +256,20 @@
     {
         if (nPos2 == nLen)
             return false;
-        const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nPos2 - nPos - 1).c_str());
+        const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nPos2 - nPos - 1));
         if (cmd.empty())
             return false;
 
         m_miCmdData.strMiCmd = cmd;
 
         if (nPos2 < nLen)
-            m_miCmdData.strMiCmdOption = CMIUtilString(vTextLine.substr(nPos2 + 1, nLen - nPos2 - 1).c_str());
+            m_miCmdData.strMiCmdOption = CMIUtilString(vTextLine.substr(nPos2 + 1, nLen - nPos2 - 1));
 
         bFoundCmd = true;
     }
     else
     {
-        const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nLen - nPos - 1).c_str());
+        const CMIUtilString cmd = CMIUtilString(vTextLine.substr(nPos + 1, nLen - nPos - 1));
         if (cmd.empty())
             return false;
         m_miCmdData.strMiCmd = cmd;
Index: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
@@ -1572,7 +1572,7 @@
             if (nNewLine == std::string::npos)
                 break;
 
-            const CMIUtilString line(text.substr(0, nNewLine + 1).c_str());
+            const CMIUtilString line(text.substr(0, nNewLine + 1));
             text.erase(0, nNewLine + 1);
             const bool bEscapeQuotes(true);
             CMICmnMIValueConst miValueConst(line.Escape(bEscapeQuotes));
@@ -1625,7 +1625,7 @@
             if (nNewLine == std::string::npos)
                 break;
 
-            const CMIUtilString line(text.substr(0, nNewLine + 1).c_str());
+            const CMIUtilString line(text.substr(0, nNewLine + 1));
             const bool bEscapeQuotes(true);
             CMICmnMIValueConst miValueConst(line.Escape(bEscapeQuotes));
             CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, miValueConst);
Index: lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
===================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
@@ -1613,7 +1613,7 @@
         // Parse argument:
         // *0x12345
         //  ^^^^^^^ -- address
-        const CMIUtilString strAddress(strLocation.c_str() + 1);
+        const CMIUtilString strAddress(strLocation.substr(1));
         strCmdOptionsLocation = CMIUtilString::Format("--address %s", strAddress.c_str());
     }
     else
@@ -1629,8 +1629,8 @@
         // hello.cpp:5
         // ^^^^^^^^^ -- file
         //           ^ -- line
-        const CMIUtilString strFile(strLocation.substr(0, nLineStartPos).c_str());
-        const CMIUtilString strLine(strLocation.substr(nLineStartPos + 1).c_str());
+        const CMIUtilString strFile(strLocation.substr(0, nLineStartPos));
+        const CMIUtilString strLine(strLocation.substr(nLineStartPos + 1));
         strCmdOptionsLocation = CMIUtilString::Format("--file \"%s\" --line %s", strFile.AddSlashes().c_str(), strLine.c_str());
     }
     const CMIUtilString strCmd(CMIUtilString::Format("target modules lookup -v %s", strCmdOptionsLocation.c_str()));
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to