[llvm] c03c4e2 - [tools] Use SmallString::operator std::string (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 00:19:43 PST 2024
Author: Kazu Hirata
Date: 2024-01-19T00:19:31-08:00
New Revision: c03c4e2b1459cc5a3c40534f4a7f99144126fbf4
URL: https://github.com/llvm/llvm-project/commit/c03c4e2b1459cc5a3c40534f4a7f99144126fbf4
DIFF: https://github.com/llvm/llvm-project/commit/c03c4e2b1459cc5a3c40534f4a7f99144126fbf4.diff
LOG: [tools] Use SmallString::operator std::string (NFC)
Added:
Modified:
llvm/tools/bugpoint/ExecutionDriver.cpp
llvm/tools/bugpoint/Miscompilation.cpp
llvm/tools/bugpoint/OptimizerDriver.cpp
llvm/tools/bugpoint/ToolRunner.cpp
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llvm-config/llvm-config.cpp
llvm/tools/llvm-cov/SourceCoverageView.cpp
llvm/tools/llvm-cov/gcov.cpp
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
llvm/tools/llvm-lto/llvm-lto.cpp
llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
llvm/tools/llvm-rc/llvm-rc.cpp
Removed:
################################################################################
diff --git a/llvm/tools/bugpoint/ExecutionDriver.cpp b/llvm/tools/bugpoint/ExecutionDriver.cpp
index 2b06e8f3b3651d..18187ad97ddddc 100644
--- a/llvm/tools/bugpoint/ExecutionDriver.cpp
+++ b/llvm/tools/bugpoint/ExecutionDriver.cpp
@@ -299,7 +299,7 @@ Expected<std::string> BugDriver::executeProgram(const Module &Program,
<< "!\n";
exit(1);
}
- BitcodeFile = std::string(UniqueFilename.str());
+ BitcodeFile = std::string(UniqueFilename);
if (writeProgramToFile(BitcodeFile, UniqueFD, Program)) {
errs() << ToolName << ": Error emitting bitcode to file '" << BitcodeFile
@@ -324,7 +324,7 @@ Expected<std::string> BugDriver::executeProgram(const Module &Program,
<< "\n";
exit(1);
}
- OutputFile = std::string(UniqueFile.str());
+ OutputFile = std::string(UniqueFile);
// Figure out which shared objects to run, if any.
std::vector<std::string> SharedObjs(AdditionalSOs);
diff --git a/llvm/tools/bugpoint/Miscompilation.cpp b/llvm/tools/bugpoint/Miscompilation.cpp
index 130c6fabd2d48d..22806bab83eecf 100644
--- a/llvm/tools/bugpoint/Miscompilation.cpp
+++ b/llvm/tools/bugpoint/Miscompilation.cpp
@@ -956,8 +956,7 @@ static Expected<bool> TestCodeGenerator(BugDriver &BD,
<< "Error making unique filename: " << EC.message() << "\n";
exit(1);
}
- if (BD.writeProgramToFile(std::string(TestModuleBC.str()), TestModuleFD,
- *Test)) {
+ if (BD.writeProgramToFile(std::string(TestModuleBC), TestModuleFD, *Test)) {
errs() << "Error writing bitcode to `" << TestModuleBC.str()
<< "'\nExiting.";
exit(1);
@@ -976,8 +975,7 @@ static Expected<bool> TestCodeGenerator(BugDriver &BD,
exit(1);
}
- if (BD.writeProgramToFile(std::string(SafeModuleBC.str()), SafeModuleFD,
- *Safe)) {
+ if (BD.writeProgramToFile(std::string(SafeModuleBC), SafeModuleFD, *Safe)) {
errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
exit(1);
}
@@ -985,7 +983,7 @@ static Expected<bool> TestCodeGenerator(BugDriver &BD,
FileRemover SafeModuleBCRemover(SafeModuleBC.str(), !SaveTemps);
Expected<std::string> SharedObject =
- BD.compileSharedObject(std::string(SafeModuleBC.str()));
+ BD.compileSharedObject(std::string(SafeModuleBC));
if (Error E = SharedObject.takeError())
return std::move(E);
@@ -994,7 +992,7 @@ static Expected<bool> TestCodeGenerator(BugDriver &BD,
// Run the code generator on the `Test' code, loading the shared library.
// The function returns whether or not the new output
diff ers from reference.
Expected<bool> Result = BD.
diff Program(
- BD.getProgram(), std::string(TestModuleBC.str()), *SharedObject, false);
+ BD.getProgram(), std::string(TestModuleBC), *SharedObject, false);
if (Error E = Result.takeError())
return std::move(E);
@@ -1051,8 +1049,7 @@ Error BugDriver::debugCodeGenerator() {
exit(1);
}
- if (writeProgramToFile(std::string(TestModuleBC.str()), TestModuleFD,
- *ToCodeGen)) {
+ if (writeProgramToFile(std::string(TestModuleBC), TestModuleFD, *ToCodeGen)) {
errs() << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
exit(1);
}
@@ -1068,13 +1065,13 @@ Error BugDriver::debugCodeGenerator() {
exit(1);
}
- if (writeProgramToFile(std::string(SafeModuleBC.str()), SafeModuleFD,
+ if (writeProgramToFile(std::string(SafeModuleBC), SafeModuleFD,
*ToNotCodeGen)) {
errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
exit(1);
}
Expected<std::string> SharedObject =
- compileSharedObject(std::string(SafeModuleBC.str()));
+ compileSharedObject(std::string(SafeModuleBC));
if (Error E = SharedObject.takeError())
return E;
diff --git a/llvm/tools/bugpoint/OptimizerDriver.cpp b/llvm/tools/bugpoint/OptimizerDriver.cpp
index f7239f5dc61bd1..ce324594724cac 100644
--- a/llvm/tools/bugpoint/OptimizerDriver.cpp
+++ b/llvm/tools/bugpoint/OptimizerDriver.cpp
@@ -141,7 +141,7 @@ bool BugDriver::runPasses(Module &Program,
<< ": Error making unique filename: " << EC.message() << "\n";
return true;
}
- OutputFilename = std::string(UniqueFilename.str());
+ OutputFilename = std::string(UniqueFilename);
// set up the input file name
Expected<sys::fs::TempFile> Temp =
diff --git a/llvm/tools/bugpoint/ToolRunner.cpp b/llvm/tools/bugpoint/ToolRunner.cpp
index c6733aecd31d40..e45c89b746aeb7 100644
--- a/llvm/tools/bugpoint/ToolRunner.cpp
+++ b/llvm/tools/bugpoint/ToolRunner.cpp
@@ -442,7 +442,7 @@ Expected<CC::FileType> LLC::OutputCode(const std::string &Bitcode,
errs() << "Error making unique filename: " << EC.message() << "\n";
exit(1);
}
- OutputAsmFile = std::string(UniqueFile.str());
+ OutputAsmFile = std::string(UniqueFile);
std::vector<StringRef> LLCArgs;
LLCArgs.push_back(LLCPath);
@@ -772,7 +772,7 @@ Error CC::MakeSharedObject(const std::string &InputFile, FileType fileType,
errs() << "Error making unique filename: " << EC.message() << "\n";
exit(1);
}
- OutputFile = std::string(UniqueFilename.str());
+ OutputFile = std::string(UniqueFilename);
std::vector<StringRef> CCArgs;
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index df0df3634882e0..b0e988c6f8e4b8 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -601,9 +601,9 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) {
}
sys::path::append(Path, "Contents", "Resources");
- std::string ResourceDir = std::string(Path.str());
+ std::string ResourceDir = std::string(Path);
sys::path::append(Path, "DWARF", sys::path::filename(DwarfFile));
- return OutputLocation(std::string(Path.str()), ResourceDir);
+ return OutputLocation(std::string(Path), ResourceDir);
}
int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) {
diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
index f31098eb67ccaa..d5b76b1bb6c16c 100644
--- a/llvm/tools/llvm-config/llvm-config.cpp
+++ b/llvm/tools/llvm-config/llvm-config.cpp
@@ -359,18 +359,18 @@ int main(int argc, char **argv) {
{
SmallString<256> Path(LLVM_INSTALL_INCLUDEDIR);
sys::fs::make_absolute(ActivePrefix, Path);
- ActiveIncludeDir = std::string(Path.str());
+ ActiveIncludeDir = std::string(Path);
}
{
SmallString<256> Path(LLVM_TOOLS_INSTALL_DIR);
sys::fs::make_absolute(ActivePrefix, Path);
- ActiveBinDir = std::string(Path.str());
+ ActiveBinDir = std::string(Path);
}
ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
{
SmallString<256> Path(LLVM_INSTALL_PACKAGE_DIR);
sys::fs::make_absolute(ActivePrefix, Path);
- ActiveCMakeDir = std::string(Path.str());
+ ActiveCMakeDir = std::string(Path);
}
ActiveIncludeOption = "-I" + ActiveIncludeDir;
}
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp
index c910edd1db7827..b92c62df7950ac 100644
--- a/llvm/tools/llvm-cov/SourceCoverageView.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp
@@ -48,7 +48,7 @@ std::string CoveragePrinter::getOutputPath(StringRef Path, StringRef Extension,
sys::path::append(FullPath, PathFilename);
sys::path::native(FullPath);
- return std::string(FullPath.str());
+ return std::string(FullPath);
}
Expected<CoveragePrinter::OwnedStream>
@@ -163,7 +163,7 @@ std::string SourceCoverageView::getSourceName() const {
SmallString<128> SourceText(SourceName);
sys::path::remove_dots(SourceText, /*remove_dot_dot=*/true);
sys::path::native(SourceText);
- return std::string(SourceText.str());
+ return std::string(SourceText);
}
void SourceCoverageView::addExpansion(
diff --git a/llvm/tools/llvm-cov/gcov.cpp b/llvm/tools/llvm-cov/gcov.cpp
index 9a1ebebc87fc8a..00ea12415b220e 100644
--- a/llvm/tools/llvm-cov/gcov.cpp
+++ b/llvm/tools/llvm-cov/gcov.cpp
@@ -35,12 +35,10 @@ static void reportCoverage(StringRef SourceFile, StringRef ObjectDir,
// A file was given. Ignore the source file and look next to this file.
sys::path::replace_extension(CoverageFileStem, "");
- std::string GCNO = InputGCNO.empty()
- ? std::string(CoverageFileStem.str()) + ".gcno"
- : InputGCNO;
- std::string GCDA = InputGCDA.empty()
- ? std::string(CoverageFileStem.str()) + ".gcda"
- : InputGCDA;
+ std::string GCNO =
+ InputGCNO.empty() ? std::string(CoverageFileStem) + ".gcno" : InputGCNO;
+ std::string GCDA =
+ InputGCDA.empty() ? std::string(CoverageFileStem) + ".gcda" : InputGCDA;
GCOVFile GF;
// Open .gcda and .gcda without requiring a NUL terminator. The concurrent
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index bc43c2d06324cc..eb1393ad94ff93 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -639,7 +639,7 @@ BenchmarkRunner::writeObjectFile(StringRef Buffer, StringRef FileName) const {
raw_fd_ostream OFS(ResultFD, true /*ShouldClose*/);
OFS.write(Buffer.data(), Buffer.size());
OFS.flush();
- return std::string(ResultPath.str());
+ return std::string(ResultPath);
}
BenchmarkRunner::FunctionExecutor::~FunctionExecutor() {}
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp
index 4141aa85d08604..735b3763f5b2fa 100644
--- a/llvm/tools/llvm-lto/llvm-lto.cpp
+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
@@ -526,7 +526,7 @@ static std::string getThinLTOOutputFile(StringRef Path, StringRef OldPrefix,
if (std::error_code EC = llvm::sys::fs::create_directories(ParentPath))
error(EC, "error creating the directory '" + ParentPath + "'");
}
- return std::string(NewPath.str());
+ return std::string(NewPath);
}
namespace thinlto {
diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
index 5810c70a664ff1..9da14cc52d6cb4 100644
--- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
+++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
@@ -1574,7 +1574,7 @@ int main(int Argc, const char **Argv) {
if (opts::yaml2pdb::YamlPdbOutputFile.empty()) {
SmallString<16> OutputFilename(opts::yaml2pdb::InputFilename.getValue());
sys::path::replace_extension(OutputFilename, ".pdb");
- opts::yaml2pdb::YamlPdbOutputFile = std::string(OutputFilename.str());
+ opts::yaml2pdb::YamlPdbOutputFile = std::string(OutputFilename);
}
yamlToPdb(opts::yaml2pdb::InputFilename);
} else if (opts::DiaDumpSubcommand) {
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index ec366766364984..1c3379a3a96786 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -561,7 +561,7 @@ RcOptions parseRcOptions(ArrayRef<const char *> ArgsArr,
SmallString<128> OutputFile(Opts.InputFile);
llvm::sys::fs::make_absolute(OutputFile);
llvm::sys::path::replace_extension(OutputFile, "res");
- OutArgsInfo.push_back(std::string(OutputFile.str()));
+ OutArgsInfo.push_back(std::string(OutputFile));
}
if (!Opts.IsDryRun) {
if (OutArgsInfo.size() != 1)
More information about the llvm-commits
mailing list