Skip to content

Commit 6c0b1e7

Browse files
committed
[llvm][tools] Strip unneeded uses of raw_string_ostream::str() (NFC)
Remove unnecessary layer of indirection.
1 parent 9cd9377 commit 6c0b1e7

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

llvm/tools/llvm-debuginfo-analyzer/llvm-debuginfo-analyzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static void error(std::error_code EC, char const *Fmt, const Ts &...Vals) {
3434
std::string Buffer;
3535
raw_string_ostream Stream(Buffer);
3636
Stream << format(Fmt, Vals...);
37-
WithColor::error(errs(), ToolName) << Stream.str() << "\n";
37+
WithColor::error(errs(), ToolName) << Buffer << "\n";
3838
exit(1);
3939
}
4040

llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static Error validateArchitectureName(StringRef ArchitectureName) {
183183
return createStringError(
184184
std::errc::invalid_argument,
185185
"invalid architecture '%s': valid architecture names are %s",
186-
ArchitectureName.str().c_str(), OS.str().c_str());
186+
ArchitectureName.str().c_str(), Buf.c_str());
187187
}
188188
return Error::success();
189189
}

llvm/tools/llvm-lipo/llvm-lipo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static void validateArchitectureName(StringRef ArchitectureName) {
142142
<< "\nValid architecture names are:";
143143
for (auto arch : MachOObjectFile::getValidArchs())
144144
OS << " " << arch;
145-
reportError(OS.str());
145+
reportError(Buf);
146146
}
147147
}
148148

@@ -241,7 +241,7 @@ static Config parseLipoOptions(ArrayRef<const char *> ArgsArr) {
241241
OS << "only one of the following actions can be specified:";
242242
for (auto *Arg : ActionArgs)
243243
OS << " " << Arg->getSpelling();
244-
reportError(OS.str());
244+
reportError(Buf);
245245
}
246246

247247
switch (ActionArgs[0]->getOption().getID()) {

llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static std::string formatSymbol(StringRef Name, uint64_t Address,
106106
else
107107
OS << format("0x%" PRIX64, Address);
108108

109-
return OS.str();
109+
return Buffer;
110110
}
111111

112112
namespace llvm {
@@ -305,7 +305,7 @@ ErrorOr<SymbolRef> Decoder::getSymbolForLocation(
305305
std::string Buf;
306306
llvm::raw_string_ostream OS(Buf);
307307
logAllUnhandledErrors(AddressOrErr.takeError(), OS);
308-
report_fatal_error(Twine(OS.str()));
308+
report_fatal_error(Twine(Buf));
309309
}
310310
// We apply SymbolOffset here directly. We return it separately to allow
311311
// the caller to print it as an offset on the symbol name.
@@ -1125,7 +1125,7 @@ bool Decoder::dumpXDataRecord(const COFFObjectFile &COFF,
11251125
std::string Buf;
11261126
llvm::raw_string_ostream OS(Buf);
11271127
logAllUnhandledErrors(Name.takeError(), OS);
1128-
report_fatal_error(Twine(OS.str()));
1128+
report_fatal_error(Twine(Buf));
11291129
}
11301130

11311131
ListScope EHS(SW, "ExceptionHandler");
@@ -1164,7 +1164,7 @@ bool Decoder::dumpUnpackedEntry(const COFFObjectFile &COFF,
11641164
std::string Buf;
11651165
llvm::raw_string_ostream OS(Buf);
11661166
logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
1167-
report_fatal_error(Twine(OS.str()));
1167+
report_fatal_error(Twine(Buf));
11681168
}
11691169
FunctionName = *FunctionNameOrErr;
11701170
}
@@ -1178,7 +1178,7 @@ bool Decoder::dumpUnpackedEntry(const COFFObjectFile &COFF,
11781178
std::string Buf;
11791179
llvm::raw_string_ostream OS(Buf);
11801180
logAllUnhandledErrors(Name.takeError(), OS);
1181-
report_fatal_error(Twine(OS.str()));
1181+
report_fatal_error(Twine(Buf));
11821182
}
11831183

11841184
SW.printString("ExceptionRecord",
@@ -1223,7 +1223,7 @@ bool Decoder::dumpPackedEntry(const object::COFFObjectFile &COFF,
12231223
std::string Buf;
12241224
llvm::raw_string_ostream OS(Buf);
12251225
logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
1226-
report_fatal_error(Twine(OS.str()));
1226+
report_fatal_error(Twine(Buf));
12271227
}
12281228
FunctionName = *FunctionNameOrErr;
12291229
}
@@ -1322,7 +1322,7 @@ bool Decoder::dumpPackedARM64Entry(const object::COFFObjectFile &COFF,
13221322
std::string Buf;
13231323
llvm::raw_string_ostream OS(Buf);
13241324
logAllUnhandledErrors(FunctionNameOrErr.takeError(), OS);
1325-
report_fatal_error(Twine(OS.str()));
1325+
report_fatal_error(Twine(Buf));
13261326
}
13271327
FunctionName = *FunctionNameOrErr;
13281328
}

llvm/tools/llvm-xray/xray-graph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ GraphRenderer::TimeStat::getString(GraphRenderer::StatType T) const {
368368
static_cast<int>(GraphRenderer::StatType::MIN)];
369369
break;
370370
}
371-
return S.str();
371+
return St;
372372
}
373373

374374
// Returns the quotient between the property T of this and another TimeStat as

0 commit comments

Comments
 (0)