[llvm] 6c0b1e7 - [llvm][tools] Strip unneeded uses of raw_string_ostream::str() (NFC)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 13 03:54:21 PDT 2024
Author: JOE1994
Date: 2024-09-13T06:23:54-04:00
New Revision: 6c0b1e75e367e73cc6d1b59d557f513beb34afd0
URL: https://github.com/llvm/llvm-project/commit/6c0b1e75e367e73cc6d1b59d557f513beb34afd0
DIFF: https://github.com/llvm/llvm-project/commit/6c0b1e75e367e73cc6d1b59d557f513beb34afd0.diff
LOG: [llvm][tools] Strip unneeded uses of raw_string_ostream::str() (NFC)
Remove unnecessary layer of indirection.
Added:
Modified:
llvm/tools/llvm-debuginfo-analyzer/llvm-debuginfo-analyzer.cpp
llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
llvm/tools/llvm-lipo/llvm-lipo.cpp
llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
llvm/tools/llvm-xray/xray-graph.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-debuginfo-analyzer/llvm-debuginfo-analyzer.cpp b/llvm/tools/llvm-debuginfo-analyzer/llvm-debuginfo-analyzer.cpp
index fb82ec0b80e755..0ce8e1e9e99f01 100644
--- a/llvm/tools/llvm-debuginfo-analyzer/llvm-debuginfo-analyzer.cpp
+++ b/llvm/tools/llvm-debuginfo-analyzer/llvm-debuginfo-analyzer.cpp
@@ -34,7 +34,7 @@ static void error(std::error_code EC, char const *Fmt, const Ts &...Vals) {
std::string Buffer;
raw_string_ostream Stream(Buffer);
Stream << format(Fmt, Vals...);
- WithColor::error(errs(), ToolName) << Stream.str() << "\n";
+ WithColor::error(errs(), ToolName) << Buffer << "\n";
exit(1);
}
diff --git a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
index 77ae9b41d88854..3d3f3f0af4b7a7 100644
--- a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
+++ b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
@@ -183,7 +183,7 @@ static Error validateArchitectureName(StringRef ArchitectureName) {
return createStringError(
std::errc::invalid_argument,
"invalid architecture '%s': valid architecture names are %s",
- ArchitectureName.str().c_str(), OS.str().c_str());
+ ArchitectureName.str().c_str(), Buf.c_str());
}
return Error::success();
}
diff --git a/llvm/tools/llvm-lipo/llvm-lipo.cpp b/llvm/tools/llvm-lipo/llvm-lipo.cpp
index 083a922af0c4c6..711a9185e155f6 100644
--- a/llvm/tools/llvm-lipo/llvm-lipo.cpp
+++ b/llvm/tools/llvm-lipo/llvm-lipo.cpp
@@ -142,7 +142,7 @@ static void validateArchitectureName(StringRef ArchitectureName) {
<< "\nValid architecture names are:";
for (auto arch : MachOObjectFile::getValidArchs())
OS << " " << arch;
- reportError(OS.str());
+ reportError(Buf);
}
}
@@ -241,7 +241,7 @@ static Config parseLipoOptions(ArrayRef<const char *> ArgsArr) {
OS << "only one of the following actions can be specified:";
for (auto *Arg : ActionArgs)
OS << " " << Arg->getSpelling();
- reportError(OS.str());
+ reportError(Buf);
}
switch (ActionArgs[0]->getOption().getID()) {
diff --git a/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp b/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
index b77839c2c57c11..08baa037eab27d 100644
--- a/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
+++ b/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
@@ -106,7 +106,7 @@ static std::string formatSymbol(StringRef Name, uint64_t Address,
else
OS << format("0x%" PRIX64, Address);
- return OS.str();
+ return Buffer;
}
namespace llvm {
@@ -305,7 +305,7 @@ ErrorOr<SymbolRef> Decoder::getSymbolForLocation(
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(AddressOrErr.takeError(), OS);
- report_fatal_error(Twine(OS.str()));
+ report_fatal_error(Twine(Buf));
}
// We apply SymbolOffset here directly. We return it separately to allow
// the caller to print it as an offset on the symbol name.
@@ -1125,7 +1125,7 @@ bool Decoder::dumpXDataRecord(const COFFObjectFile &COFF,
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(Name.takeError(), OS);
- report_fatal_error(Twine(OS.str()));
+ report_fatal_error(Twine(Buf));
}
ListScope EHS(SW, "ExceptionHandler");
@@ -1164,7 +1164,7 @@ bool Decoder::dumpUnpackedEntry(const COFFObjectFile &COFF,
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
- report_fatal_error(Twine(OS.str()));
+ report_fatal_error(Twine(Buf));
}
FunctionName = *FunctionNameOrErr;
}
@@ -1178,7 +1178,7 @@ bool Decoder::dumpUnpackedEntry(const COFFObjectFile &COFF,
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(Name.takeError(), OS);
- report_fatal_error(Twine(OS.str()));
+ report_fatal_error(Twine(Buf));
}
SW.printString("ExceptionRecord",
@@ -1223,7 +1223,7 @@ bool Decoder::dumpPackedEntry(const object::COFFObjectFile &COFF,
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
- report_fatal_error(Twine(OS.str()));
+ report_fatal_error(Twine(Buf));
}
FunctionName = *FunctionNameOrErr;
}
@@ -1322,7 +1322,7 @@ bool Decoder::dumpPackedARM64Entry(const object::COFFObjectFile &COFF,
std::string Buf;
llvm::raw_string_ostream OS(Buf);
logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
- report_fatal_error(Twine(OS.str()));
+ report_fatal_error(Twine(Buf));
}
FunctionName = *FunctionNameOrErr;
}
diff --git a/llvm/tools/llvm-xray/xray-graph.cpp b/llvm/tools/llvm-xray/xray-graph.cpp
index de67993d759016..a97aacfd67b7ac 100644
--- a/llvm/tools/llvm-xray/xray-graph.cpp
+++ b/llvm/tools/llvm-xray/xray-graph.cpp
@@ -368,7 +368,7 @@ GraphRenderer::TimeStat::getString(GraphRenderer::StatType T) const {
static_cast<int>(GraphRenderer::StatType::MIN)];
break;
}
- return S.str();
+ return St;
}
// Returns the quotient between the property T of this and another TimeStat as
More information about the llvm-commits
mailing list