[Lldb-commits] [lldb] r241360 - [lldb-mi] Use size_t where appropriate.
Bruce Mitchener
bruce.mitchener at gmail.com
Fri Jul 3 08:40:44 PDT 2015
Author: brucem
Date: Fri Jul 3 10:40:44 2015
New Revision: 241360
URL: http://llvm.org/viewvc/llvm-project?rev=241360&view=rev
Log:
[lldb-mi] Use size_t where appropriate.
Summary:
Many places should have been using size_t rather than MIuint or
MIint. This is particularly true for code that uses std::string::find(),
std::string::rfind(), std::string::size(), and related methods.
Reviewers: abidh, ki.stfu, domipheus
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D10931
Modified:
lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp
lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp
lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp
lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdSymbol.cpp
lldb/trunk/tools/lldb-mi/MICmdFactory.cpp
lldb/trunk/tools/lldb-mi/MICmdInterpreter.cpp
lldb/trunk/tools/lldb-mi/MICmnLogMediumFile.cpp
lldb/trunk/tools/lldb-mi/MIDriver.cpp
lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp
lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp
lldb/trunk/tools/lldb-mi/MIUtilString.cpp
lldb/trunk/tools/lldb-mi/MIUtilString.h
Modified: lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp Fri Jul 3 10:40:44 2015
@@ -85,16 +85,16 @@ CMICmdArgContext::RemoveArg(const CMIUti
if (vArg.empty())
return MIstatus::success;
- const MIuint nLen = vArg.length();
- const MIuint nLenCntxt = m_strCmdArgsAndOptions.length();
+ const size_t nLen = vArg.length();
+ const size_t nLenCntxt = m_strCmdArgsAndOptions.length();
if (nLen > nLenCntxt)
return MIstatus::failure;
- MIuint nExtraSpace = 0;
- MIint nPos = m_strCmdArgsAndOptions.find(vArg);
+ size_t nExtraSpace = 0;
+ size_t nPos = m_strCmdArgsAndOptions.find(vArg);
while (1)
{
- if (nPos == (MIint)std::string::npos)
+ if (nPos == std::string::npos)
return MIstatus::success;
bool bPass1 = false;
@@ -106,7 +106,7 @@ CMICmdArgContext::RemoveArg(const CMIUti
else
bPass1 = true;
- const MIuint nEnd = nPos + nLen;
+ const size_t nEnd = nPos + nLen;
if (bPass1)
{
@@ -129,7 +129,7 @@ CMICmdArgContext::RemoveArg(const CMIUti
nPos = m_strCmdArgsAndOptions.find(vArg, nEnd);
}
- const MIuint nPosEnd = nLen + nExtraSpace;
+ const size_t nPosEnd = nLen + nExtraSpace;
m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, "").c_str();
m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp Fri Jul 3 10:40:44 2015
@@ -122,8 +122,8 @@ CMICmdArgValFile::GetFileNamePath(const
// Look for a space in the path
const char cSpace = ' ';
- const MIint nPos = fileNamePath.find(cSpace);
- if (nPos != (MIint)std::string::npos)
+ const size_t nPos = fileNamePath.find(cSpace);
+ if (nPos != std::string::npos)
fileNamePath = CMIUtilString::Format("\"%s\"", fileNamePath.c_str());
return fileNamePath;
@@ -146,7 +146,7 @@ CMICmdArgValFile::IsFilePath(const CMIUt
const bool bHaveBckSlash = (vrFileNamePath.find_first_of("\\") != std::string::npos);
// Look for --someLongOption
- MIint nPos = vrFileNamePath.find_first_of("--");
+ size_t nPos = vrFileNamePath.find_first_of("--");
const bool bLong = (nPos == 0);
if (bLong)
return false;
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp Fri Jul 3 10:40:44 2015
@@ -254,7 +254,7 @@ CMICmdArgValOptionLong::IsArgLongOption(
if (bHavePosSlash || bHaveBckSlash)
return false;
- const MIint nPos = vrTxt.find_first_of("--");
+ const size_t nPos = vrTxt.find_first_of("--");
if (nPos != 0)
return false;
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp Fri Jul 3 10:40:44 2015
@@ -263,12 +263,12 @@ CMICmdArgValString::IsStringArgQuotedTex
// CODETAG_QUOTEDTEXT_SIMILAR_CODE
const char cQuote = '"';
- const MIint nPos = vrTxt.find(cQuote);
- if (nPos == (MIint)std::string::npos)
+ const size_t nPos = vrTxt.find(cQuote);
+ if (nPos == std::string::npos)
return false;
// Is one and only quote at end of the string
- if (nPos == (MIint)(vrTxt.length() - 1))
+ if (nPos == (vrTxt.length() - 1))
return false;
// Quote must be the first character in the string or be preceded by a space
@@ -283,8 +283,8 @@ CMICmdArgValString::IsStringArgQuotedTex
return false;
// Need to find the other quote
- const MIint nPos2 = vrTxt.rfind(cQuote);
- if (nPos2 == (MIint)std::string::npos)
+ const size_t nPos2 = vrTxt.rfind(cQuote);
+ if (nPos2 == std::string::npos)
return false;
// Make sure not same quote, need two quotes
@@ -309,8 +309,8 @@ CMICmdArgValString::IsStringArgQuotedTex
{
// CODETAG_QUOTEDTEXT_SIMILAR_CODE
const char cBckSlash = '\\';
- const MIint nPos = vrTxt.find(cBckSlash);
- if (nPos == (MIint)std::string::npos)
+ const size_t nPos = vrTxt.find(cBckSlash);
+ if (nPos == std::string::npos)
return false;
// Slash must be the first character in the string or be preceded by a space
@@ -319,8 +319,8 @@ CMICmdArgValString::IsStringArgQuotedTex
return false;
// Need to find the other matching slash
- const MIint nPos2 = vrTxt.rfind(cBckSlash);
- if (nPos2 == (MIint)std::string::npos)
+ const size_t nPos2 = vrTxt.rfind(cBckSlash);
+ if (nPos2 == std::string::npos)
return false;
// Make sure not same back slash, need two slashes
@@ -343,15 +343,15 @@ CMICmdArgValString::IsStringArgQuotedTex
bool
CMICmdArgValString::IsStringArgQuotedQuotedTextEmbedded(const CMIUtilString &vrTxt) const
{
- const MIint nPos = vrTxt.find("\"\\\"");
- if (nPos == (MIint)std::string::npos)
+ const size_t nPos = vrTxt.find("\"\\\"");
+ if (nPos == std::string::npos)
return false;
- const MIint nPos2 = vrTxt.rfind("\\\"\"");
- if (nPos2 == (MIint)std::string::npos)
+ const size_t nPos2 = vrTxt.rfind("\\\"\"");
+ if (nPos2 == std::string::npos)
return false;
- const MIint nLen = vrTxt.length();
+ const size_t nLen = vrTxt.length();
if ((nLen > 5) && ((nPos + 2) == (nPos2 - 2)))
return false;
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp Fri Jul 3 10:40:44 2015
@@ -1681,8 +1681,8 @@ CMICmdCmdDataInfoLine::Execute(void)
}
else
{
- const MIuint nLineStartPos = strLocation.rfind(':');
- if ((nLineStartPos == (MIuint)std::string::npos) || (nLineStartPos == 0) || (nLineStartPos == strLocation.length() - 1))
+ const size_t nLineStartPos = strLocation.rfind(':');
+ if ((nLineStartPos == std::string::npos) || (nLineStartPos == 0) || (nLineStartPos == strLocation.length() - 1))
{
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_LOCATION_FORMAT), m_cmdData.strMiCmd.c_str(), strLocation.c_str())
.c_str());
@@ -1739,9 +1739,9 @@ CMICmdCmdDataInfoLine::Acknowledge(void)
// LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1]
// ^^^^^^^^^ -- property
- const MIuint nPropertyStartPos = rLine.find_first_not_of(' ');
- const MIuint nPropertyEndPos = rLine.find(':');
- const MIuint nPropertyLen = nPropertyEndPos - nPropertyStartPos;
+ const size_t nPropertyStartPos = rLine.find_first_not_of(' ');
+ const size_t nPropertyEndPos = rLine.find(':');
+ const size_t nPropertyLen = nPropertyEndPos - nPropertyStartPos;
const CMIUtilString strProperty(rLine.substr(nPropertyStartPos, nPropertyLen).c_str());
// Skip all except LineEntry
@@ -1750,9 +1750,9 @@ CMICmdCmdDataInfoLine::Acknowledge(void)
// LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1]
// ^^^^^^^^^^^^^^^^^^ -- start address
- const MIuint nStartAddressStartPos = rLine.find("[");
- const MIuint nStartAddressEndPos = rLine.find("-");
- const MIuint nStartAddressLen = nStartAddressEndPos - nStartAddressStartPos - 1;
+ const size_t nStartAddressStartPos = rLine.find("[");
+ const size_t nStartAddressEndPos = rLine.find("-");
+ const size_t nStartAddressLen = nStartAddressEndPos - nStartAddressStartPos - 1;
const CMIUtilString strStartAddress(rLine.substr(nStartAddressStartPos + 1, nStartAddressLen).c_str());
const CMICmnMIValueConst miValueConst(strStartAddress);
const CMICmnMIValueResult miValueResult("start", miValueConst);
@@ -1760,8 +1760,8 @@ CMICmdCmdDataInfoLine::Acknowledge(void)
// LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1]
// ^^^^^^^^^^^^^^^^^^ -- end address
- const MIuint nEndAddressEndPos = rLine.find(")");
- const MIuint nEndAddressLen = nEndAddressEndPos - nStartAddressEndPos - 1;
+ const size_t nEndAddressEndPos = rLine.find(")");
+ const size_t nEndAddressLen = nEndAddressEndPos - nStartAddressEndPos - 1;
const CMIUtilString strEndAddress(rLine.substr(nStartAddressEndPos + 1, nEndAddressLen).c_str());
const CMICmnMIValueConst miValueConst2(strEndAddress);
const CMICmnMIValueResult miValueResult2("end", miValueConst2);
@@ -1773,11 +1773,11 @@ CMICmdCmdDataInfoLine::Acknowledge(void)
// ^^^^^^^^^^^^^ -- file
// ^ -- line
// ^ -- column (optional)
- const MIuint nFileStartPos = rLine.find_first_not_of(' ', nEndAddressEndPos + 2);
- const MIuint nFileOrLineEndPos = rLine.rfind(':');
- const MIuint nFileOrLineStartPos = rLine.rfind(':', nFileOrLineEndPos - 1);
- const MIuint nFileEndPos = nFileStartPos < nFileOrLineStartPos ? nFileOrLineStartPos : nFileOrLineEndPos;
- const MIuint nFileLen = nFileEndPos - nFileStartPos;
+ const size_t nFileStartPos = rLine.find_first_not_of(' ', nEndAddressEndPos + 2);
+ const size_t nFileOrLineEndPos = rLine.rfind(':');
+ const size_t nFileOrLineStartPos = rLine.rfind(':', nFileOrLineEndPos - 1);
+ const size_t nFileEndPos = nFileStartPos < nFileOrLineStartPos ? nFileOrLineStartPos : nFileOrLineEndPos;
+ const size_t nFileLen = nFileEndPos - nFileStartPos;
const CMIUtilString strFile(rLine.substr(nFileStartPos, nFileLen).c_str());
const CMICmnMIValueConst miValueConst3(strFile);
const CMICmnMIValueResult miValueResult3("file", miValueConst3);
@@ -1787,10 +1787,10 @@ CMICmdCmdDataInfoLine::Acknowledge(void)
// LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1]
// ^ -- line
- const MIuint nLineStartPos = nFileEndPos + 1;
- const MIuint nLineEndPos = rLine.find(':', nLineStartPos);
- const MIuint nLineLen = nLineEndPos != (MIuint)std::string::npos ? nLineEndPos - nLineStartPos - 1
- : (MIuint)std::string::npos;
+ const size_t nLineStartPos = nFileEndPos + 1;
+ const size_t nLineEndPos = rLine.find(':', nLineStartPos);
+ const size_t nLineLen = nLineEndPos != std::string::npos ? nLineEndPos - nLineStartPos - 1
+ : std::string::npos;
const CMIUtilString strLine(rLine.substr(nLineStartPos, nLineLen).c_str());
const CMICmnMIValueConst miValueConst4(strLine);
const CMICmnMIValueResult miValueResult4("line", miValueConst4);
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdSymbol.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdSymbol.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdSymbol.cpp Fri Jul 3 10:40:44 2015
@@ -126,7 +126,7 @@ CMICmdCmdSymbolListLines::Acknowledge(vo
// 0x0000000100000e70: /path/to/file:3[:4]
// ^^^^^^^^^^^^^^^^^^ -- pc
- const MIuint nAddrEndPos = rLine.find(':');
+ const size_t nAddrEndPos = rLine.find(':');
const CMIUtilString strAddr(rLine.substr(0, nAddrEndPos).c_str());
const CMICmnMIValueConst miValueConst(strAddr);
const CMICmnMIValueResult miValueResult("pc", miValueConst);
@@ -134,10 +134,10 @@ CMICmdCmdSymbolListLines::Acknowledge(vo
// 0x0000000100000e70: /path/to/file:3[:4]
// ^ -- line
- const MIuint nLineOrColumnStartPos = rLine.rfind(':');
+ const size_t nLineOrColumnStartPos = rLine.rfind(':');
const CMIUtilString strLineOrColumn(rLine.substr(nLineOrColumnStartPos + 1).c_str());
- const MIuint nPathOrLineStartPos = rLine.rfind(':', nLineOrColumnStartPos - 1);
- const MIuint nPathOrLineLen = nLineOrColumnStartPos - nPathOrLineStartPos - 1;
+ const size_t nPathOrLineStartPos = rLine.rfind(':', nLineOrColumnStartPos - 1);
+ const size_t nPathOrLineLen = nLineOrColumnStartPos - nPathOrLineStartPos - 1;
const CMIUtilString strPathOrLine(rLine.substr(nPathOrLineStartPos + 1, nPathOrLineLen).c_str());
const CMIUtilString strLine(strPathOrLine.IsNumber() ? strPathOrLine : strLineOrColumn);
const CMICmnMIValueConst miValueConst2(strLine);
Modified: lldb/trunk/tools/lldb-mi/MICmdFactory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdFactory.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdFactory.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdFactory.cpp Fri Jul 3 10:40:44 2015
@@ -159,8 +159,8 @@ CMICmdFactory::IsValid(const CMIUtilStri
return false;
}
- const MIint nPos = vMiCmd.find(" ");
- if (nPos != (MIint)std::string::npos)
+ const size_t nPos = vMiCmd.find(" ");
+ if (nPos != std::string::npos)
bValid = false;
return bValid;
Modified: lldb/trunk/tools/lldb-mi/MICmdInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdInterpreter.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdInterpreter.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdInterpreter.cpp Fri Jul 3 10:40:44 2015
@@ -153,8 +153,8 @@ bool
CMICmdInterpreter::MiHasCmdTokenEndingHyphen(const CMIUtilString &vTextLine)
{
// The hyphen is mandatory
- const MIint nPos = vTextLine.find("-", 0);
- if ((nPos == (MIint)std::string::npos))
+ const size_t nPos = vTextLine.find("-", 0);
+ if ((nPos == std::string::npos))
return false;
if (MiHasCmdTokenPresent(vTextLine))
@@ -215,7 +215,7 @@ CMICmdInterpreter::MiHasCmdTokenEndingAl
bool
CMICmdInterpreter::MiHasCmdTokenPresent(const CMIUtilString &vTextLine)
{
- const MIint nPos = vTextLine.find("-", 0);
+ const size_t nPos = vTextLine.find("-", 0);
return (nPos > 0);
}
@@ -233,11 +233,11 @@ CMICmdInterpreter::MiHasCmdTokenPresent(
bool
CMICmdInterpreter::MiHasCmd(const CMIUtilString &vTextLine)
{
- MIint nPos = 0;
+ size_t nPos = 0;
if (m_miCmdData.bMIOldStyle)
{
char cChar = vTextLine[0];
- MIuint i = 0;
+ size_t i = 0;
while (::isdigit(cChar) != 0)
{
cChar = vTextLine[++i];
@@ -250,9 +250,9 @@ CMICmdInterpreter::MiHasCmd(const CMIUti
}
bool bFoundCmd = false;
- const MIint nLen = vTextLine.length();
- const MIint nPos2 = vTextLine.find(" ", nPos);
- if (nPos2 != (MIint)std::string::npos)
+ const size_t nLen = vTextLine.length();
+ const size_t nPos2 = vTextLine.find(" ", nPos);
+ if (nPos2 != std::string::npos)
{
if (nPos2 == nLen)
return false;
Modified: lldb/trunk/tools/lldb-mi/MICmnLogMediumFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLogMediumFile.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLogMediumFile.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLogMediumFile.cpp Fri Jul 3 10:40:44 2015
@@ -283,8 +283,8 @@ CMICmnLogMediumFile::MassagedData(const
data = ConvertCr(data);
// Look for EOL...
- const MIint pos = vData.rfind(strCr);
- if (pos == (MIint)vData.size())
+ const size_t pos = vData.rfind(strCr);
+ if (pos == vData.size())
return data;
// ... did not have an EOL so add one
@@ -382,11 +382,11 @@ CMICmnLogMediumFile::ConvertCr(const CMI
if (strCr == rCrCmpat)
return vData;
- const MIuint nSizeCmpat(rCrCmpat.size());
- const MIuint nSize(strCr.size());
+ const size_t nSizeCmpat(rCrCmpat.size());
+ const size_t nSize(strCr.size());
CMIUtilString strConv(vData);
- MIint pos = strConv.find(strCr);
- while (pos != (MIint)CMIUtilString::npos)
+ size_t pos = strConv.find(strCr);
+ while (pos != CMIUtilString::npos)
{
strConv.replace(pos, nSize, rCrCmpat);
pos = strConv.find(strCr, pos + nSizeCmpat);
Modified: lldb/trunk/tools/lldb-mi/MIDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIDriver.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MIDriver.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MIDriver.cpp Fri Jul 3 10:40:44 2015
@@ -862,7 +862,7 @@ CMIDriver::WrapCLICommandIntoMICommand(c
// Also possible case when command not found:
// 001
// ^ -- i.e. only tokens are present (or empty string at all)
- const MIuint nCommandOffset = vTextLine.find_first_not_of(digits);
+ const size_t nCommandOffset = vTextLine.find_first_not_of(digits);
// 2. Check if command is empty
// For example:
@@ -872,7 +872,7 @@ CMIDriver::WrapCLICommandIntoMICommand(c
// or:
// 001
// ^ -- command wasn't found
- const bool bIsEmptyCommand = (nCommandOffset == (MIuint)CMIUtilString::npos);
+ const bool bIsEmptyCommand = (nCommandOffset == CMIUtilString::npos);
// 3. Check and exit if it isn't a CLI command
// For example:
Modified: lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp Fri Jul 3 10:40:44 2015
@@ -518,7 +518,7 @@ CMIDriverMgr::ParseArgs(const int argc,
}
if (0 == strArg.compare(0,10,"--log-dir="))
{
- strLogDir = strArg.substr(10,CMIUtilString::npos);
+ strLogDir = strArg.substr(10, CMIUtilString::npos);
bHaveArgLogDir = true;
}
if ((0 == strArg.compare("--help")) || (0 == strArg.compare("-h")))
Modified: lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp Fri Jul 3 10:40:44 2015
@@ -256,9 +256,9 @@ CMIUtilFileStd::GetLineReturn(void) cons
CMIUtilString
CMIUtilFileStd::StripOffFileName(const CMIUtilString &vDirectoryPath)
{
- const MIint nPos = vDirectoryPath.rfind('\\');
- MIint nPos2 = vDirectoryPath.rfind('/');
- if ((nPos == (MIint)std::string::npos) && (nPos2 == (MIint)std::string::npos))
+ const size_t nPos = vDirectoryPath.rfind('\\');
+ size_t nPos2 = vDirectoryPath.rfind('/');
+ if ((nPos == std::string::npos) && (nPos2 == std::string::npos))
return vDirectoryPath;
if (nPos > nPos2)
Modified: lldb/trunk/tools/lldb-mi/MIUtilString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIUtilString.cpp?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MIUtilString.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MIUtilString.cpp Fri Jul 3 10:40:44 2015
@@ -202,10 +202,10 @@ CMIUtilString::FormatValist(const CMIUti
// Args: vData - (R) String data to be split up.
// vDelimiter - (R) Delimiter char or text.
// vwVecSplits - (W) Container of splits found in string data.
-// Return: MIuint - Number of splits found in the string data.
+// Return: size_t - Number of splits found in the string data.
// Throws: None.
//--
-MIuint
+size_t
CMIUtilString::Split(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits) const
{
vwVecSplits.clear();
@@ -213,22 +213,22 @@ CMIUtilString::Split(const CMIUtilString
if (this->empty() || vDelimiter.empty())
return 0;
- const MIuint nLen(length());
- MIuint nOffset(0);
+ const size_t nLen(length());
+ size_t nOffset(0);
do
{
// Find first occurrence which doesn't match to the delimiter
- const MIuint nSectionPos(FindFirstNot(vDelimiter, nOffset));
- if (nSectionPos == (MIuint)std::string::npos)
+ const size_t nSectionPos(FindFirstNot(vDelimiter, nOffset));
+ if (nSectionPos == std::string::npos)
break;
// Find next occurrence of the delimiter after section
- MIuint nNextDelimiterPos(FindFirst(vDelimiter, nSectionPos));
- if (nNextDelimiterPos == (MIuint)std::string::npos)
+ size_t nNextDelimiterPos(FindFirst(vDelimiter, nSectionPos));
+ if (nNextDelimiterPos == std::string::npos)
nNextDelimiterPos = nLen;
// Extract string between delimiters
- const MIuint nSectionLen(nNextDelimiterPos - nSectionPos);
+ const size_t nSectionLen(nNextDelimiterPos - nSectionPos);
const std::string strSection(substr(nSectionPos, nSectionLen));
vwVecSplits.push_back(strSection.c_str());
@@ -251,10 +251,10 @@ CMIUtilString::Split(const CMIUtilString
// Args: vData - (R) String data to be split up.
// vDelimiter - (R) Delimiter char or text.
// vwVecSplits - (W) Container of splits found in string data.
-// Return: MIuint - Number of splits found in the string data.
+// Return: size_t - Number of splits found in the string data.
// Throws: None.
//--
-MIuint
+size_t
CMIUtilString::SplitConsiderQuotes(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits) const
{
vwVecSplits.clear();
@@ -262,29 +262,29 @@ CMIUtilString::SplitConsiderQuotes(const
if (this->empty() || vDelimiter.empty())
return 0;
- const MIuint nLen(length());
- MIuint nOffset(0);
+ const size_t nLen(length());
+ size_t nOffset(0);
do
{
// Find first occurrence which doesn't match to the delimiter
- const MIuint nSectionPos(FindFirstNot(vDelimiter, nOffset));
- if (nSectionPos == (MIuint)std::string::npos)
+ const size_t nSectionPos(FindFirstNot(vDelimiter, nOffset));
+ if (nSectionPos == std::string::npos)
break;
// Find next occurrence of the delimiter after (quoted) section
const bool bSkipQuotedText(true);
bool bUnmatchedQuote(false);
- MIuint nNextDelimiterPos(FindFirst(vDelimiter, bSkipQuotedText, bUnmatchedQuote, nSectionPos));
+ size_t nNextDelimiterPos(FindFirst(vDelimiter, bSkipQuotedText, bUnmatchedQuote, nSectionPos));
if (bUnmatchedQuote)
{
vwVecSplits.clear();
return 0;
}
- if (nNextDelimiterPos == (MIuint)std::string::npos)
+ if (nNextDelimiterPos == std::string::npos)
nNextDelimiterPos = nLen;
// Extract string between delimiters
- const MIuint nSectionLen(nNextDelimiterPos - nSectionPos);
+ const size_t nSectionLen(nNextDelimiterPos - nSectionPos);
const std::string strSection(substr(nSectionPos, nSectionLen));
vwVecSplits.push_back(strSection.c_str());
@@ -300,10 +300,10 @@ CMIUtilString::SplitConsiderQuotes(const
// Details: Split string into lines using \n and return an array of strings.
// Type: Method.
// Args: vwVecSplits - (W) Container of splits found in string data.
-// Return: MIuint - Number of splits found in the string data.
+// Return: size_t - Number of splits found in the string data.
// Throws: None.
//--
-MIuint
+size_t
CMIUtilString::SplitLines(VecString_t &vwVecSplits) const
{
return Split("\n", vwVecSplits);
@@ -320,8 +320,8 @@ CMIUtilString::SplitLines(VecString_t &v
CMIUtilString
CMIUtilString::StripCREndOfLine(void) const
{
- const MIint nPos = rfind('\n');
- if (nPos == (MIint)std::string::npos)
+ const size_t nPos = rfind('\n');
+ if (nPos == std::string::npos)
return *this;
const CMIUtilString strNew(substr(0, nPos).c_str());
@@ -358,12 +358,12 @@ CMIUtilString::FindAndReplace(const CMIU
if (vFind.empty() || this->empty())
return *this;
- MIint nPos = find(vFind);
- if (nPos == (MIint)std::string::npos)
+ size_t nPos = find(vFind);
+ if (nPos == std::string::npos)
return *this;
CMIUtilString strNew(*this);
- while (nPos != (MIint)std::string::npos)
+ while (nPos != std::string::npos)
{
strNew.replace(nPos, vFind.length(), vReplaceWith);
nPos += vReplaceWith.length();
@@ -389,8 +389,8 @@ CMIUtilString::IsNumber(void) const
if ((at(0) == '-') && (length() == 1))
return false;
- const MIint nPos = find_first_not_of("-.0123456789");
- if (nPos != (MIint)std::string::npos)
+ const size_t nPos = find_first_not_of("-.0123456789");
+ if (nPos != std::string::npos)
return false;
return true;
@@ -411,8 +411,8 @@ CMIUtilString::IsHexadecimalNumber(void)
return false;
// Skip '0x..' prefix
- const MIint nPos = find_first_not_of("01234567890ABCDEFabcedf", 2);
- if (nPos != (MIint)std::string::npos)
+ const size_t nPos = find_first_not_of("01234567890ABCDEFabcedf", 2);
+ if (nPos != std::string::npos)
return false;
return true;
@@ -457,8 +457,8 @@ CMIUtilString::ExtractNumberFromHexadeci
{
vwrNumber = 0;
- const MIint nPos = find_first_not_of("xX01234567890ABCDEFabcedf");
- if (nPos != (MIint)std::string::npos)
+ const size_t nPos = find_first_not_of("xX01234567890ABCDEFabcedf");
+ if (nPos != std::string::npos)
return false;
errno = 0;
@@ -482,11 +482,11 @@ CMIUtilString::ExtractNumberFromHexadeci
bool
CMIUtilString::IsAllValidAlphaAndNumeric(const char *vpText)
{
- const MIuint len = ::strlen(vpText);
+ const size_t len = ::strlen(vpText);
if (len == 0)
return false;
- for (MIuint i = 0; i < len; i++, vpText++)
+ for (size_t i = 0; i < len; i++, vpText++)
{
const char c = *vpText;
if (::isalnum((int)c) == 0)
@@ -526,13 +526,13 @@ CMIUtilString::Trim(void) const
{
CMIUtilString strNew(*this);
const char *pWhiteSpace = " \t\n\v\f\r";
- const MIint nPos = find_last_not_of(pWhiteSpace);
- if (nPos != (MIint)std::string::npos)
+ const size_t nPos = find_last_not_of(pWhiteSpace);
+ if (nPos != std::string::npos)
{
strNew = substr(0, nPos + 1).c_str();
}
- const MIint nPos2 = strNew.find_first_not_of(pWhiteSpace);
- if (nPos2 != (MIint)std::string::npos)
+ const size_t nPos2 = strNew.find_first_not_of(pWhiteSpace);
+ if (nPos2 != std::string::npos)
{
strNew = strNew.substr(nPos2).c_str();
}
@@ -551,7 +551,7 @@ CMIUtilString
CMIUtilString::Trim(const char vChar) const
{
CMIUtilString strNew(*this);
- const MIint nLen = strNew.length();
+ const size_t nLen = strNew.length();
if (nLen > 1)
{
if ((strNew[0] == vChar) && (strNew[nLen - 1] == vChar))
@@ -617,22 +617,22 @@ CMIUtilString::RemoveRepeatedCharacters(
// character.
// Type: Method.
// Args: vChar - (R) The character to search for and remove adjacent duplicates.
-// vnPos - (R) Character position in the string.
+// vnPos - Character position in the string.
// Return: CMIUtilString - New version of the string.
// Throws: None.
//--
CMIUtilString
-CMIUtilString::RemoveRepeatedCharacters(const MIint vnPos, const char vChar)
+CMIUtilString::RemoveRepeatedCharacters(size_t vnPos, const char vChar)
{
const char cQuote = '"';
// Look for first quote of two
- MIint nPos = find(cQuote, vnPos);
- if (nPos == (MIint)std::string::npos)
+ const size_t nPos = find(cQuote, vnPos);
+ if (nPos == std::string::npos)
return *this;
- const MIint nPosNext = nPos + 1;
- if (nPosNext > (MIint)length())
+ const size_t nPosNext = nPos + 1;
+ if (nPosNext > length())
return *this;
if (at(nPosNext) == cQuote)
@@ -659,7 +659,7 @@ CMIUtilString::IsQuoted(void) const
if (at(0) != cQuote)
return false;
- const MIint nLen = length();
+ const size_t nLen = length();
if ((nLen > 0) && (at(nLen - 1) != cQuote))
return false;
@@ -670,12 +670,12 @@ CMIUtilString::IsQuoted(void) const
// Details: Find first occurrence in *this string which matches the pattern.
// Type: Method.
// Args: vrPattern - (R) The pattern to search for.
-// vnPos - (R) The starting position at which to start searching. (Dflt = 0)
-// Return: MIuint - The position of the first substring that match.
+// vnPos - The starting position at which to start searching. (Dflt = 0)
+// Return: size_t - The position of the first substring that match.
// Throws: None.
//--
-MIuint
-CMIUtilString::FindFirst(const CMIUtilString &vrPattern, const MIuint vnPos /* = 0 */) const
+size_t
+CMIUtilString::FindFirst(const CMIUtilString &vrPattern, size_t vnPos /* = 0 */) const
{
return find(vrPattern, vnPos);
}
@@ -686,61 +686,61 @@ CMIUtilString::FindFirst(const CMIUtilSt
// Args: vrPattern - (R) The pattern to search for.
// vbSkipQuotedText - (R) True = don't look at quoted text, false = otherwise.
// vrwbNotFoundClosedQuote - (W) True = parsing error: unmatched quote, false = otherwise.
-// vnPos - (R) Position of the first character in the string to be considered in the search. (Dflt = 0)
-// Return: MIuint - The position of the first substring that matches and isn't quoted.
+// vnPos - Position of the first character in the string to be considered in the search. (Dflt = 0)
+// Return: size_t - The position of the first substring that matches and isn't quoted.
// Throws: None.
//--
-MIuint
+size_t
CMIUtilString::FindFirst(const CMIUtilString &vrPattern, const bool vbSkipQuotedText, bool &vrwbNotFoundClosedQuote,
- const MIuint vnPos /* = 0 */) const
+ size_t vnPos /* = 0 */) const
{
vrwbNotFoundClosedQuote = false;
if (!vbSkipQuotedText)
return FindFirst(vrPattern, vnPos);
- const MIuint nLen(length());
+ const size_t nLen(length());
- MIuint nPos = vnPos;
+ size_t nPos = vnPos;
do
{
- const MIuint nQuotePos(FindFirstQuote(nPos));
- const MIuint nPatternPos(FindFirst(vrPattern, nPos));
- if (nQuotePos == (MIuint)std::string::npos)
+ const size_t nQuotePos(FindFirstQuote(nPos));
+ const size_t nPatternPos(FindFirst(vrPattern, nPos));
+ if (nQuotePos == std::string::npos)
return nPatternPos;
- const MIuint nQuoteClosedPos = FindFirstQuote(nQuotePos + 1);
- if (nQuoteClosedPos == (MIuint)std::string::npos)
+ const size_t nQuoteClosedPos = FindFirstQuote(nQuotePos + 1);
+ if (nQuoteClosedPos == std::string::npos)
{
vrwbNotFoundClosedQuote = true;
- return (MIuint)std::string::npos;
+ return std::string::npos;
}
- if ((nPatternPos == (MIuint)std::string::npos) || (nPatternPos < nQuotePos))
+ if ((nPatternPos == std::string::npos) || (nPatternPos < nQuotePos))
return nPatternPos;
nPos = nQuoteClosedPos + 1;
}
while (nPos < nLen);
- return (MIuint)std::string::npos;
+ return std::string::npos;
}
//++ ------------------------------------------------------------------------------------
// Details: Find first occurrence in *this string which doesn't match the pattern.
// Type: Method.
// Args: vrPattern - (R) The pattern to search for.
-// vnPos - (R) Position of the first character in the string to be considered in the search. (Dflt = 0)
-// Return: MIuint - The position of the first character that doesn't match.
+// vnPos - Position of the first character in the string to be considered in the search. (Dflt = 0)
+// Return: size_t - The position of the first character that doesn't match.
// Throws: None.
//--
-MIuint
-CMIUtilString::FindFirstNot(const CMIUtilString &vrPattern, const MIuint vnPos /* = 0 */) const
+size_t
+CMIUtilString::FindFirstNot(const CMIUtilString &vrPattern, size_t vnPos /* = 0 */) const
{
- const MIuint nLen(length());
- const MIuint nPatternLen(vrPattern.length());
+ const size_t nLen(length());
+ const size_t nPatternLen(vrPattern.length());
- MIuint nPatternPos(vnPos);
+ size_t nPatternPos(vnPos);
do
{
const bool bMatchPattern(compare(nPatternPos, nPatternLen, vrPattern) == 0);
@@ -750,29 +750,29 @@ CMIUtilString::FindFirstNot(const CMIUti
}
while (nPatternPos < nLen);
- return (MIuint)std::string::npos;
+ return std::string::npos;
}
//++ ------------------------------------------------------------------------------------
// Details: Find first occurrence of not escaped quotation mark in *this string.
// Type: Method.
-// Args: vnPos - (R) Position of the first character in the string to be considered in the search.
-// Return: MIuint - The position of the quotation mark.
+// Args: vnPos - Position of the first character in the string to be considered in the search.
+// Return: size_t - The position of the quotation mark.
// Throws: None.
//--
-MIuint
-CMIUtilString::FindFirstQuote(const MIuint vnPos) const
+size_t
+CMIUtilString::FindFirstQuote(size_t vnPos) const
{
const char cBckSlash('\\');
const char cQuote('"');
- const MIuint nLen(length());
+ const size_t nLen(length());
- MIuint nPos = vnPos;
+ size_t nPos = vnPos;
do
{
- const MIuint nBckSlashPos(find(cBckSlash, nPos));
- const MIuint nQuotePos(find(cQuote, nPos));
- if ((nBckSlashPos == (MIuint)std::string::npos) || (nQuotePos == (MIuint)std::string::npos))
+ const size_t nBckSlashPos(find(cBckSlash, nPos));
+ const size_t nQuotePos(find(cQuote, nPos));
+ if ((nBckSlashPos == std::string::npos) || (nQuotePos == std::string::npos))
return nQuotePos;
if (nQuotePos < nBckSlashPos)
@@ -783,7 +783,7 @@ CMIUtilString::FindFirstQuote(const MIui
}
while (nPos < nLen);
- return (MIuint)std::string::npos;
+ return std::string::npos;
}
//++ ------------------------------------------------------------------------------------
@@ -794,12 +794,12 @@ CMIUtilString::FindFirstQuote(const MIui
// Throws: None.
//--
CMIUtilString
-CMIUtilString::Escape(const bool vbEscapeQuotes /* = false */) const
+CMIUtilString::Escape(bool vbEscapeQuotes /* = false */) const
{
- const MIuint nLen(length());
+ const size_t nLen(length());
CMIUtilString strNew;
strNew.reserve(nLen);
- for (MIuint nIndex(0); nIndex < nLen; ++nIndex)
+ for (size_t nIndex(0); nIndex < nLen; ++nIndex)
{
const char cUnescapedChar((*this)[nIndex]);
if (cUnescapedChar == '"' && vbEscapeQuotes)
@@ -822,22 +822,22 @@ CMIUtilString
CMIUtilString::AddSlashes(void) const
{
const char cBckSlash('\\');
- const MIuint nLen(length());
+ const size_t nLen(length());
CMIUtilString strNew;
strNew.reserve(nLen);
- MIuint nOffset(0);
+ size_t nOffset(0);
while (nOffset < nLen)
{
- const MIuint nUnescapedCharPos(find_first_of("\"\\", nOffset));
- const bool bUnescapedCharNotFound(nUnescapedCharPos == (MIuint)std::string::npos);
+ const size_t nUnescapedCharPos(find_first_of("\"\\", nOffset));
+ const bool bUnescapedCharNotFound(nUnescapedCharPos == std::string::npos);
if (bUnescapedCharNotFound)
{
- const MIuint nAppendAll((MIuint)std::string::npos);
+ const size_t nAppendAll(std::string::npos);
strNew.append(*this, nOffset, nAppendAll);
break;
}
- const MIuint nAppendLen(nUnescapedCharPos - nOffset);
+ const size_t nAppendLen(nUnescapedCharPos - nOffset);
strNew.append(*this, nOffset, nAppendLen);
strNew.push_back(cBckSlash);
const char cUnescapedChar((*this)[nUnescapedCharPos]);
@@ -859,22 +859,22 @@ CMIUtilString
CMIUtilString::StripSlashes(void) const
{
const char cBckSlash('\\');
- const MIuint nLen(length());
+ const size_t nLen(length());
CMIUtilString strNew;
strNew.reserve(nLen);
- MIuint nOffset(0);
+ size_t nOffset(0);
while (nOffset < nLen)
{
- const MIuint nBckSlashPos(find(cBckSlash, nOffset));
- const bool bBckSlashNotFound(nBckSlashPos == (MIuint)std::string::npos);
+ const size_t nBckSlashPos(find(cBckSlash, nOffset));
+ const bool bBckSlashNotFound(nBckSlashPos == std::string::npos);
if (bBckSlashNotFound)
{
- const MIuint nAppendAll((MIuint)std::string::npos);
+ const size_t nAppendAll(std::string::npos);
strNew.append(*this, nOffset, nAppendAll);
break;
}
- const MIuint nAppendLen(nBckSlashPos - nOffset);
+ const size_t nAppendLen(nBckSlashPos - nOffset);
strNew.append(*this, nOffset, nAppendLen);
const bool bBckSlashIsLast(nBckSlashPos == nLen);
if (bBckSlashIsLast)
@@ -883,8 +883,8 @@ CMIUtilString::StripSlashes(void) const
break;
}
const char cEscapedChar((*this)[nBckSlashPos + 1]);
- const MIuint nEscapedCharPos(std::string("\"\\").find(cEscapedChar));
- const bool bEscapedCharNotFound(nEscapedCharPos == (MIuint)std::string::npos);
+ const size_t nEscapedCharPos(std::string("\"\\").find(cEscapedChar));
+ const bool bEscapedCharNotFound(nEscapedCharPos == std::string::npos);
if (bEscapedCharNotFound)
strNew.push_back(cBckSlash);
strNew.push_back(cEscapedChar);
Modified: lldb/trunk/tools/lldb-mi/MIUtilString.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIUtilString.h?rev=241360&r1=241359&r2=241360&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MIUtilString.h (original)
+++ lldb/trunk/tools/lldb-mi/MIUtilString.h Fri Jul 3 10:40:44 2015
@@ -53,18 +53,18 @@ class CMIUtilString : public std::string
bool IsHexadecimalNumber(void) const;
bool IsQuoted(void) const;
CMIUtilString RemoveRepeatedCharacters(const char vChar);
- MIuint Split(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits) const;
- MIuint SplitConsiderQuotes(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits) const;
- MIuint SplitLines(VecString_t &vwVecSplits) const;
+ size_t Split(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits) const;
+ size_t SplitConsiderQuotes(const CMIUtilString &vDelimiter, VecString_t &vwVecSplits) const;
+ size_t SplitLines(VecString_t &vwVecSplits) const;
CMIUtilString StripCREndOfLine(void) const;
CMIUtilString StripCRAll(void) const;
CMIUtilString Trim(void) const;
CMIUtilString Trim(const char vChar) const;
- MIuint FindFirst(const CMIUtilString &vrPattern, const MIuint vnPos = 0) const;
- MIuint FindFirst(const CMIUtilString &vrPattern, const bool vbSkipQuotedText, bool &vrwbNotFoundClosedQuote,
- const MIuint vnPos = 0) const;
- MIuint FindFirstNot(const CMIUtilString &vrPattern, const MIuint vnPos = 0) const;
- CMIUtilString Escape(const bool vbEscapeQuotes = false) const;
+ size_t FindFirst(const CMIUtilString &vrPattern, size_t vnPos = 0) const;
+ size_t FindFirst(const CMIUtilString &vrPattern, bool vbSkipQuotedText, bool &vrwbNotFoundClosedQuote,
+ size_t vnPos = 0) const;
+ size_t FindFirstNot(const CMIUtilString &vrPattern, size_t vnPos = 0) const;
+ CMIUtilString Escape(bool vbEscapeQuotes = false) const;
CMIUtilString AddSlashes(void) const;
CMIUtilString StripSlashes(void) const;
//
@@ -82,6 +82,6 @@ class CMIUtilString : public std::string
// Methods:
private:
bool ExtractNumberFromHexadecimal(MIint64 &vwrNumber) const;
- CMIUtilString RemoveRepeatedCharacters(const MIint vnPos, const char vChar);
- MIuint FindFirstQuote(const MIuint vnPos) const;
+ CMIUtilString RemoveRepeatedCharacters(size_t vnPos, const char vChar);
+ size_t FindFirstQuote(size_t vnPos) const;
};
More information about the lldb-commits
mailing list