[llvm] Replace SmallStr.str().str() with std::string conversion operator.

Use the std::string conversion operator introduced in
d7049213d0.
This commit is contained in:
Jonas Devlieghere 2020-01-29 21:14:15 -08:00
parent 14a16fae43
commit b2924d9956
9 changed files with 24 additions and 23 deletions

View File

@ -349,7 +349,7 @@ void codegen(const Config &Conf, TargetMachine *TM, AddStreamFn AddStream,
DwoFile = Conf.DwoDir; DwoFile = Conf.DwoDir;
sys::path::append(DwoFile, std::to_string(Task) + ".dwo"); sys::path::append(DwoFile, std::to_string(Task) + ".dwo");
TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str(); TM->Options.MCOptions.SplitDwarfFile = std::string(DwoFile);
} else } else
TM->Options.MCOptions.SplitDwarfFile = Conf.SplitDwarfFile; TM->Options.MCOptions.SplitDwarfFile = Conf.SplitDwarfFile;

View File

@ -693,7 +693,7 @@ std::string FileInfo::getCoveragePath(StringRef Filename,
MD5::MD5Result Result; MD5::MD5Result Result;
Hasher.update(Filename.str()); Hasher.update(Filename.str());
Hasher.final(Result); Hasher.final(Result);
CoveragePath += "##" + Result.digest().str().str(); CoveragePath += "##" + std::string(Result.digest());
} }
CoveragePath += ".gcov"; CoveragePath += ".gcov";
return CoveragePath; return CoveragePath;

View File

@ -1642,7 +1642,7 @@ bool Scanner::scanBlockScalar(bool IsLiteral) {
Token T; Token T;
T.Kind = Token::TK_BlockScalar; T.Kind = Token::TK_BlockScalar;
T.Range = StringRef(Start, Current - Start); T.Range = StringRef(Start, Current - Start);
T.Value = Str.str().str(); T.Value = std::string(Str);
TokenQueue.push_back(T); TokenQueue.push_back(T);
return true; return true;
} }

View File

@ -96,7 +96,7 @@ static std::string findInputFile(StringRef File, ArrayRef<StringRef> Paths) {
SmallString<128> Path = Dir; SmallString<128> Path = Dir;
sys::path::append(Path, File); sys::path::append(Path, File);
if (sys::fs::exists(Path)) if (sys::fs::exists(Path))
return Path.str().str(); return std::string(Path);
} }
return ""; return "";
} }

View File

@ -96,7 +96,7 @@ SymbolMapTranslator SymbolMapLoader::Load(StringRef InputFile,
StringRef UUID(CFStringGetCStringPtr(OldUUID, kCFStringEncodingUTF8)); StringRef UUID(CFStringGetCStringPtr(OldUUID, kCFStringEncodingUTF8));
SmallString<256> BCSymbolMapPath(SymbolMapPath); SmallString<256> BCSymbolMapPath(SymbolMapPath);
sys::path::append(BCSymbolMapPath, UUID.str() + ".bcsymbolmap"); sys::path::append(BCSymbolMapPath, UUID.str() + ".bcsymbolmap");
SymbolMapPath = BCSymbolMapPath.str().str(); SymbolMapPath = std::string(BCSymbolMapPath);
} }
CFRelease(plist); CFRelease(plist);
} }

View File

@ -471,7 +471,7 @@ static std::unique_ptr<symbolize::LLVMSymbolizer> createSymbolizer() {
static std::string normalizeFilename(const std::string &FileName) { static std::string normalizeFilename(const std::string &FileName) {
SmallString<256> S(FileName); SmallString<256> S(FileName);
sys::path::remove_dots(S, /* remove_dot_dot */ true); sys::path::remove_dots(S, /* remove_dot_dot */ true);
return stripPathPrefix(S.str().str()); return stripPathPrefix(std::string(S));
} }
class Blacklists { class Blacklists {

View File

@ -1357,53 +1357,53 @@ TEST(APIntTest, toString) {
bool isSigned; bool isSigned;
APInt(8, 0).toString(S, 2, true, true); APInt(8, 0).toString(S, 2, true, true);
EXPECT_EQ(S.str().str(), "0b0"); EXPECT_EQ(std::string(S), "0b0");
S.clear(); S.clear();
APInt(8, 0).toString(S, 8, true, true); APInt(8, 0).toString(S, 8, true, true);
EXPECT_EQ(S.str().str(), "00"); EXPECT_EQ(std::string(S), "00");
S.clear(); S.clear();
APInt(8, 0).toString(S, 10, true, true); APInt(8, 0).toString(S, 10, true, true);
EXPECT_EQ(S.str().str(), "0"); EXPECT_EQ(std::string(S), "0");
S.clear(); S.clear();
APInt(8, 0).toString(S, 16, true, true); APInt(8, 0).toString(S, 16, true, true);
EXPECT_EQ(S.str().str(), "0x0"); EXPECT_EQ(std::string(S), "0x0");
S.clear(); S.clear();
APInt(8, 0).toString(S, 36, true, false); APInt(8, 0).toString(S, 36, true, false);
EXPECT_EQ(S.str().str(), "0"); EXPECT_EQ(std::string(S), "0");
S.clear(); S.clear();
isSigned = false; isSigned = false;
APInt(8, 255, isSigned).toString(S, 2, isSigned, true); APInt(8, 255, isSigned).toString(S, 2, isSigned, true);
EXPECT_EQ(S.str().str(), "0b11111111"); EXPECT_EQ(std::string(S), "0b11111111");
S.clear(); S.clear();
APInt(8, 255, isSigned).toString(S, 8, isSigned, true); APInt(8, 255, isSigned).toString(S, 8, isSigned, true);
EXPECT_EQ(S.str().str(), "0377"); EXPECT_EQ(std::string(S), "0377");
S.clear(); S.clear();
APInt(8, 255, isSigned).toString(S, 10, isSigned, true); APInt(8, 255, isSigned).toString(S, 10, isSigned, true);
EXPECT_EQ(S.str().str(), "255"); EXPECT_EQ(std::string(S), "255");
S.clear(); S.clear();
APInt(8, 255, isSigned).toString(S, 16, isSigned, true); APInt(8, 255, isSigned).toString(S, 16, isSigned, true);
EXPECT_EQ(S.str().str(), "0xFF"); EXPECT_EQ(std::string(S), "0xFF");
S.clear(); S.clear();
APInt(8, 255, isSigned).toString(S, 36, isSigned, false); APInt(8, 255, isSigned).toString(S, 36, isSigned, false);
EXPECT_EQ(S.str().str(), "73"); EXPECT_EQ(std::string(S), "73");
S.clear(); S.clear();
isSigned = true; isSigned = true;
APInt(8, 255, isSigned).toString(S, 2, isSigned, true); APInt(8, 255, isSigned).toString(S, 2, isSigned, true);
EXPECT_EQ(S.str().str(), "-0b1"); EXPECT_EQ(std::string(S), "-0b1");
S.clear(); S.clear();
APInt(8, 255, isSigned).toString(S, 8, isSigned, true); APInt(8, 255, isSigned).toString(S, 8, isSigned, true);
EXPECT_EQ(S.str().str(), "-01"); EXPECT_EQ(std::string(S), "-01");
S.clear(); S.clear();
APInt(8, 255, isSigned).toString(S, 10, isSigned, true); APInt(8, 255, isSigned).toString(S, 10, isSigned, true);
EXPECT_EQ(S.str().str(), "-1"); EXPECT_EQ(std::string(S), "-1");
S.clear(); S.clear();
APInt(8, 255, isSigned).toString(S, 16, isSigned, true); APInt(8, 255, isSigned).toString(S, 16, isSigned, true);
EXPECT_EQ(S.str().str(), "-0x1"); EXPECT_EQ(std::string(S), "-0x1");
S.clear(); S.clear();
APInt(8, 255, isSigned).toString(S, 36, isSigned, false); APInt(8, 255, isSigned).toString(S, 36, isSigned, false);
EXPECT_EQ(S.str().str(), "-1"); EXPECT_EQ(std::string(S), "-1");
S.clear(); S.clear();
} }

View File

@ -38,7 +38,8 @@ TEST(writeFileAtomicallyTest, Test) {
SmallString<128> FinalTestfilePath(RootTestDirectory); SmallString<128> FinalTestfilePath(RootTestDirectory);
sys::path::append(FinalTestfilePath, "foo.txt"); sys::path::append(FinalTestfilePath, "foo.txt");
const std::string TempUniqTestFileModel = FinalTestfilePath.str().str() + "-%%%%%%%%"; const std::string TempUniqTestFileModel =
std::string(FinalTestfilePath) + "-%%%%%%%%";
const std::string TestfileContent = "fooFOOfoo"; const std::string TestfileContent = "fooFOOfoo";
llvm::Error Err = llvm::writeFileAtomically(TempUniqTestFileModel, FinalTestfilePath, TestfileContent); llvm::Error Err = llvm::writeFileAtomically(TempUniqTestFileModel, FinalTestfilePath, TestfileContent);

View File

@ -1096,7 +1096,7 @@ TEST_F(InMemoryFileSystemTest, GetRealPath) {
SmallString<16> Output; SmallString<16> Output;
auto EC = FS.getRealPath(P, Output); auto EC = FS.getRealPath(P, Output);
EXPECT_FALSE(EC); EXPECT_FALSE(EC);
return Output.str().str(); return std::string(Output);
}; };
FS.setCurrentWorkingDirectory("a"); FS.setCurrentWorkingDirectory("a");