Skip to content

Commit c03c4e2

Browse files
[tools] Use SmallString::operator std::string (NFC)
1 parent 3b54337 commit c03c4e2

File tree

12 files changed

+27
-32
lines changed

12 files changed

+27
-32
lines changed

llvm/tools/bugpoint/ExecutionDriver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ Expected<std::string> BugDriver::executeProgram(const Module &Program,
299299
<< "!\n";
300300
exit(1);
301301
}
302-
BitcodeFile = std::string(UniqueFilename.str());
302+
BitcodeFile = std::string(UniqueFilename);
303303

304304
if (writeProgramToFile(BitcodeFile, UniqueFD, Program)) {
305305
errs() << ToolName << ": Error emitting bitcode to file '" << BitcodeFile
@@ -324,7 +324,7 @@ Expected<std::string> BugDriver::executeProgram(const Module &Program,
324324
<< "\n";
325325
exit(1);
326326
}
327-
OutputFile = std::string(UniqueFile.str());
327+
OutputFile = std::string(UniqueFile);
328328

329329
// Figure out which shared objects to run, if any.
330330
std::vector<std::string> SharedObjs(AdditionalSOs);

llvm/tools/bugpoint/Miscompilation.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -956,8 +956,7 @@ static Expected<bool> TestCodeGenerator(BugDriver &BD,
956956
<< "Error making unique filename: " << EC.message() << "\n";
957957
exit(1);
958958
}
959-
if (BD.writeProgramToFile(std::string(TestModuleBC.str()), TestModuleFD,
960-
*Test)) {
959+
if (BD.writeProgramToFile(std::string(TestModuleBC), TestModuleFD, *Test)) {
961960
errs() << "Error writing bitcode to `" << TestModuleBC.str()
962961
<< "'\nExiting.";
963962
exit(1);
@@ -976,16 +975,15 @@ static Expected<bool> TestCodeGenerator(BugDriver &BD,
976975
exit(1);
977976
}
978977

979-
if (BD.writeProgramToFile(std::string(SafeModuleBC.str()), SafeModuleFD,
980-
*Safe)) {
978+
if (BD.writeProgramToFile(std::string(SafeModuleBC), SafeModuleFD, *Safe)) {
981979
errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
982980
exit(1);
983981
}
984982

985983
FileRemover SafeModuleBCRemover(SafeModuleBC.str(), !SaveTemps);
986984

987985
Expected<std::string> SharedObject =
988-
BD.compileSharedObject(std::string(SafeModuleBC.str()));
986+
BD.compileSharedObject(std::string(SafeModuleBC));
989987
if (Error E = SharedObject.takeError())
990988
return std::move(E);
991989

@@ -994,7 +992,7 @@ static Expected<bool> TestCodeGenerator(BugDriver &BD,
994992
// Run the code generator on the `Test' code, loading the shared library.
995993
// The function returns whether or not the new output differs from reference.
996994
Expected<bool> Result = BD.diffProgram(
997-
BD.getProgram(), std::string(TestModuleBC.str()), *SharedObject, false);
995+
BD.getProgram(), std::string(TestModuleBC), *SharedObject, false);
998996
if (Error E = Result.takeError())
999997
return std::move(E);
1000998

@@ -1051,8 +1049,7 @@ Error BugDriver::debugCodeGenerator() {
10511049
exit(1);
10521050
}
10531051

1054-
if (writeProgramToFile(std::string(TestModuleBC.str()), TestModuleFD,
1055-
*ToCodeGen)) {
1052+
if (writeProgramToFile(std::string(TestModuleBC), TestModuleFD, *ToCodeGen)) {
10561053
errs() << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
10571054
exit(1);
10581055
}
@@ -1068,13 +1065,13 @@ Error BugDriver::debugCodeGenerator() {
10681065
exit(1);
10691066
}
10701067

1071-
if (writeProgramToFile(std::string(SafeModuleBC.str()), SafeModuleFD,
1068+
if (writeProgramToFile(std::string(SafeModuleBC), SafeModuleFD,
10721069
*ToNotCodeGen)) {
10731070
errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
10741071
exit(1);
10751072
}
10761073
Expected<std::string> SharedObject =
1077-
compileSharedObject(std::string(SafeModuleBC.str()));
1074+
compileSharedObject(std::string(SafeModuleBC));
10781075
if (Error E = SharedObject.takeError())
10791076
return E;
10801077

llvm/tools/bugpoint/OptimizerDriver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ bool BugDriver::runPasses(Module &Program,
141141
<< ": Error making unique filename: " << EC.message() << "\n";
142142
return true;
143143
}
144-
OutputFilename = std::string(UniqueFilename.str());
144+
OutputFilename = std::string(UniqueFilename);
145145

146146
// set up the input file name
147147
Expected<sys::fs::TempFile> Temp =

llvm/tools/bugpoint/ToolRunner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ Expected<CC::FileType> LLC::OutputCode(const std::string &Bitcode,
442442
errs() << "Error making unique filename: " << EC.message() << "\n";
443443
exit(1);
444444
}
445-
OutputAsmFile = std::string(UniqueFile.str());
445+
OutputAsmFile = std::string(UniqueFile);
446446
std::vector<StringRef> LLCArgs;
447447
LLCArgs.push_back(LLCPath);
448448

@@ -772,7 +772,7 @@ Error CC::MakeSharedObject(const std::string &InputFile, FileType fileType,
772772
errs() << "Error making unique filename: " << EC.message() << "\n";
773773
exit(1);
774774
}
775-
OutputFile = std::string(UniqueFilename.str());
775+
OutputFile = std::string(UniqueFilename);
776776

777777
std::vector<StringRef> CCArgs;
778778

llvm/tools/dsymutil/dsymutil.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,9 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) {
601601
}
602602

603603
sys::path::append(Path, "Contents", "Resources");
604-
std::string ResourceDir = std::string(Path.str());
604+
std::string ResourceDir = std::string(Path);
605605
sys::path::append(Path, "DWARF", sys::path::filename(DwarfFile));
606-
return OutputLocation(std::string(Path.str()), ResourceDir);
606+
return OutputLocation(std::string(Path), ResourceDir);
607607
}
608608

609609
int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) {

llvm/tools/llvm-config/llvm-config.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,18 +359,18 @@ int main(int argc, char **argv) {
359359
{
360360
SmallString<256> Path(LLVM_INSTALL_INCLUDEDIR);
361361
sys::fs::make_absolute(ActivePrefix, Path);
362-
ActiveIncludeDir = std::string(Path.str());
362+
ActiveIncludeDir = std::string(Path);
363363
}
364364
{
365365
SmallString<256> Path(LLVM_TOOLS_INSTALL_DIR);
366366
sys::fs::make_absolute(ActivePrefix, Path);
367-
ActiveBinDir = std::string(Path.str());
367+
ActiveBinDir = std::string(Path);
368368
}
369369
ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
370370
{
371371
SmallString<256> Path(LLVM_INSTALL_PACKAGE_DIR);
372372
sys::fs::make_absolute(ActivePrefix, Path);
373-
ActiveCMakeDir = std::string(Path.str());
373+
ActiveCMakeDir = std::string(Path);
374374
}
375375
ActiveIncludeOption = "-I" + ActiveIncludeDir;
376376
}

llvm/tools/llvm-cov/SourceCoverageView.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ std::string CoveragePrinter::getOutputPath(StringRef Path, StringRef Extension,
4848
sys::path::append(FullPath, PathFilename);
4949
sys::path::native(FullPath);
5050

51-
return std::string(FullPath.str());
51+
return std::string(FullPath);
5252
}
5353

5454
Expected<CoveragePrinter::OwnedStream>
@@ -163,7 +163,7 @@ std::string SourceCoverageView::getSourceName() const {
163163
SmallString<128> SourceText(SourceName);
164164
sys::path::remove_dots(SourceText, /*remove_dot_dot=*/true);
165165
sys::path::native(SourceText);
166-
return std::string(SourceText.str());
166+
return std::string(SourceText);
167167
}
168168

169169
void SourceCoverageView::addExpansion(

llvm/tools/llvm-cov/gcov.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ static void reportCoverage(StringRef SourceFile, StringRef ObjectDir,
3535
// A file was given. Ignore the source file and look next to this file.
3636
sys::path::replace_extension(CoverageFileStem, "");
3737

38-
std::string GCNO = InputGCNO.empty()
39-
? std::string(CoverageFileStem.str()) + ".gcno"
40-
: InputGCNO;
41-
std::string GCDA = InputGCDA.empty()
42-
? std::string(CoverageFileStem.str()) + ".gcda"
43-
: InputGCDA;
38+
std::string GCNO =
39+
InputGCNO.empty() ? std::string(CoverageFileStem) + ".gcno" : InputGCNO;
40+
std::string GCDA =
41+
InputGCDA.empty() ? std::string(CoverageFileStem) + ".gcda" : InputGCDA;
4442
GCOVFile GF;
4543

4644
// Open .gcda and .gcda without requiring a NUL terminator. The concurrent

llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ BenchmarkRunner::writeObjectFile(StringRef Buffer, StringRef FileName) const {
639639
raw_fd_ostream OFS(ResultFD, true /*ShouldClose*/);
640640
OFS.write(Buffer.data(), Buffer.size());
641641
OFS.flush();
642-
return std::string(ResultPath.str());
642+
return std::string(ResultPath);
643643
}
644644

645645
BenchmarkRunner::FunctionExecutor::~FunctionExecutor() {}

llvm/tools/llvm-lto/llvm-lto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ static std::string getThinLTOOutputFile(StringRef Path, StringRef OldPrefix,
526526
if (std::error_code EC = llvm::sys::fs::create_directories(ParentPath))
527527
error(EC, "error creating the directory '" + ParentPath + "'");
528528
}
529-
return std::string(NewPath.str());
529+
return std::string(NewPath);
530530
}
531531

532532
namespace thinlto {

llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ int main(int Argc, const char **Argv) {
15741574
if (opts::yaml2pdb::YamlPdbOutputFile.empty()) {
15751575
SmallString<16> OutputFilename(opts::yaml2pdb::InputFilename.getValue());
15761576
sys::path::replace_extension(OutputFilename, ".pdb");
1577-
opts::yaml2pdb::YamlPdbOutputFile = std::string(OutputFilename.str());
1577+
opts::yaml2pdb::YamlPdbOutputFile = std::string(OutputFilename);
15781578
}
15791579
yamlToPdb(opts::yaml2pdb::InputFilename);
15801580
} else if (opts::DiaDumpSubcommand) {

llvm/tools/llvm-rc/llvm-rc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ RcOptions parseRcOptions(ArrayRef<const char *> ArgsArr,
561561
SmallString<128> OutputFile(Opts.InputFile);
562562
llvm::sys::fs::make_absolute(OutputFile);
563563
llvm::sys::path::replace_extension(OutputFile, "res");
564-
OutArgsInfo.push_back(std::string(OutputFile.str()));
564+
OutArgsInfo.push_back(std::string(OutputFile));
565565
}
566566
if (!Opts.IsDryRun) {
567567
if (OutArgsInfo.size() != 1)

0 commit comments

Comments
 (0)