[llvm] 459a82e - [llvm][unittests] Don't call raw_string_ostream::flush() (NFC)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 13 16:59:56 PDT 2024
Author: JOE1994
Date: 2024-09-13T19:55:44-04:00
New Revision: 459a82e6890ff41e30d486f36c8c7ec22628bb7a
URL: https://github.com/llvm/llvm-project/commit/459a82e6890ff41e30d486f36c8c7ec22628bb7a
DIFF: https://github.com/llvm/llvm-project/commit/459a82e6890ff41e30d486f36c8c7ec22628bb7a.diff
LOG: [llvm][unittests] Don't call raw_string_ostream::flush() (NFC)
raw_string_ostream::flush() is essentially a no-op (also specified in docs).
Don't call it in tests that aren't meant to test 'raw_string_ostream' itself.
p.s. remove a few redundant calls to raw_string_ostream::str()
Added:
Modified:
llvm/unittests/ADT/RewriteBufferTest.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
llvm/unittests/IR/ConstantsTest.cpp
llvm/unittests/IR/ManglerTest.cpp
llvm/unittests/IR/MetadataTest.cpp
llvm/unittests/IR/ModuleSummaryIndexTest.cpp
llvm/unittests/MC/MCInstPrinter.cpp
llvm/unittests/MIR/MachineMetadata.cpp
llvm/unittests/Object/SymbolicFileTest.cpp
llvm/unittests/ProfileData/InstrProfTest.cpp
llvm/unittests/ProfileData/MemProfTest.cpp
llvm/unittests/Support/CommandLineTest.cpp
llvm/unittests/Support/CrashRecoveryTest.cpp
llvm/unittests/Support/ErrorTest.cpp
llvm/unittests/Support/FormatVariadicTest.cpp
llvm/unittests/Support/LEB128Test.cpp
llvm/unittests/Support/ModRefTest.cpp
llvm/unittests/Support/NativeFormatTests.cpp
llvm/unittests/Support/RISCVAttributeParserTest.cpp
llvm/unittests/Support/SourceMgrTest.cpp
llvm/unittests/Support/VirtualFileSystemTest.cpp
llvm/unittests/Support/YAMLIOTest.cpp
llvm/unittests/Target/RISCV/RISCVInstrInfoTest.cpp
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
llvm/unittests/XRay/FDRProducerConsumerTest.cpp
llvm/unittests/XRay/FDRRecordPrinterTest.cpp
llvm/unittests/XRay/FDRRecordsTest.cpp
llvm/unittests/XRay/FDRTraceWriterTest.cpp
llvm/unittests/tools/llvm-exegesis/ProgressMeterTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/ADT/RewriteBufferTest.cpp b/llvm/unittests/ADT/RewriteBufferTest.cpp
index 3b367daa7806e7..5746ab1d26b6fe 100644
--- a/llvm/unittests/ADT/RewriteBufferTest.cpp
+++ b/llvm/unittests/ADT/RewriteBufferTest.cpp
@@ -19,7 +19,6 @@ static std::string writeOutput(const RewriteBuffer &Buf) {
std::string Result;
raw_string_ostream OS(Result);
Buf.write(OS);
- OS.flush();
return Result;
}
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp
index d96553174536e2..17fb18fc6b4d24 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp
@@ -44,7 +44,6 @@ void expectDumpResult(const dwarf::CIE &TestCIE, bool IsEH,
auto DumpOpts = DIDumpOptions();
DumpOpts.IsEH = IsEH;
TestCIE.dump(OS, DumpOpts);
- OS.flush();
StringRef FirstLine = StringRef(Output).split('\n').first;
EXPECT_EQ(FirstLine, ExpectedFirstLine);
}
@@ -56,7 +55,6 @@ void expectDumpResult(const dwarf::FDE &TestFDE, bool IsEH,
auto DumpOpts = DIDumpOptions();
DumpOpts.IsEH = IsEH;
TestFDE.dump(OS, DumpOpts);
- OS.flush();
StringRef FirstLine = StringRef(Output).split('\n').first;
EXPECT_EQ(FirstLine, ExpectedFirstLine);
}
@@ -344,7 +342,6 @@ void expectDumpResult(const dwarf::UnwindLocation &Loc,
std::string Output;
raw_string_ostream OS(Output);
OS << Loc;
- OS.flush();
StringRef FirstLine = StringRef(Output).split('\n').first;
EXPECT_EQ(FirstLine, ExpectedFirstLine);
}
@@ -387,7 +384,6 @@ void expectDumpResult(const dwarf::RegisterLocations &Locs,
std::string Output;
raw_string_ostream OS(Output);
OS << Locs;
- OS.flush();
StringRef FirstLine = StringRef(Output).split('\n').first;
EXPECT_EQ(FirstLine, ExpectedFirstLine);
}
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
index 980b627625eef6..e549128031744e 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
@@ -1558,7 +1558,6 @@ TEST_F(DebugLineBasicFixture, VerboseOutput) {
raw_string_ostream OS(Output);
Parser.parseNext(RecordRecoverable, RecordUnrecoverable, &OS,
/*Verbose=*/true);
- OS.flush();
StringRef OutputRef(Output);
size_t Pos = 0;
@@ -1805,7 +1804,6 @@ struct TruncatedOpcodeFixtureBase : public CommonFixture {
raw_string_ostream OS(Output);
Parser.parseNext(RecordRecoverable, RecordUnrecoverable, &OS,
/*Verbose=*/true);
- OS.flush();
std::string LinePrefix =
("0x0000002f: 0" + Twine::utohexstr(OpcodeValue) + " ").str();
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
index 6934746c606389..29d4db44e7cf99 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp
@@ -375,7 +375,6 @@ TEST_P(DumpValueFixture, Test) {
Opts.ShowAddresses = true;
Form.dump(OS, Opts);
- OS.flush();
EXPECT_EQ(Output, ExpectedResult);
}
diff --git a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
index 621b6feac8d2ce..c6218e5004d178 100644
--- a/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
+++ b/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
@@ -3802,7 +3802,6 @@ TEST(GSYMTest, TestRangeWarnings) {
const uint32_t ThreadCount = 1;
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
- OS.flush();
SmallString<512> Str;
raw_svector_ostream OutStrm(Str);
const auto ByteOrder = llvm::endianness::native;
@@ -4005,7 +4004,6 @@ TEST(GSYMTest, TestEmptyRangeWarnings) {
const uint32_t ThreadCount = 1;
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
- OS.flush();
SmallString<512> Str;
raw_svector_ostream OutStrm(Str);
const auto ByteOrder = llvm::endianness::native;
@@ -4158,7 +4156,6 @@ TEST(GSYMTest, TestEmptyLinkageName) {
const uint32_t ThreadCount = 1;
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
- OS.flush();
SmallString<512> Str;
raw_svector_ostream OutStrm(Str);
const auto ByteOrder = llvm::endianness::native;
@@ -4320,7 +4317,6 @@ TEST(GSYMTest, TestLineTablesWithEmptyRanges) {
const uint32_t ThreadCount = 1;
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
- OS.flush();
SmallString<512> Str;
raw_svector_ostream OutStrm(Str);
const auto ByteOrder = llvm::endianness::native;
@@ -4641,7 +4637,6 @@ TEST(GSYMTest, TestHandlingOfInvalidFileIndexes) {
const uint32_t ThreadCount = 1;
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
- OS.flush();
SmallString<512> Str;
raw_svector_ostream OutStrm(Str);
const auto ByteOrder = llvm::endianness::native;
@@ -4857,7 +4852,6 @@ TEST(GSYMTest, TestLookupsOfOverlappingAndUnequalRanges) {
const uint32_t ThreadCount = 1;
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
- OS.flush();
SmallString<512> Str;
raw_svector_ostream OutStrm(Str);
const auto ByteOrder = llvm::endianness::native;
diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp
index 48d65be70b37b7..ed608ba57d22ca 100644
--- a/llvm/unittests/IR/ConstantsTest.cpp
+++ b/llvm/unittests/IR/ConstantsTest.cpp
@@ -172,7 +172,6 @@ TEST(ConstantsTest, PointerCast) {
Instruction *__I = cast<ConstantExpr>(x)->getAsInstruction(); \
__I->print(__o); \
__I->deleteValue(); \
- __o.flush(); \
EXPECT_EQ(std::string(" <badref> = " y), __s); \
}
diff --git a/llvm/unittests/IR/ManglerTest.cpp b/llvm/unittests/IR/ManglerTest.cpp
index f2b78a1f987694..5ac784b7e89ac6 100644
--- a/llvm/unittests/IR/ManglerTest.cpp
+++ b/llvm/unittests/IR/ManglerTest.cpp
@@ -20,7 +20,6 @@ static std::string mangleStr(StringRef IRName, Mangler &Mang,
std::string Mangled;
raw_string_ostream SS(Mangled);
Mang.getNameWithPrefix(SS, IRName, DL);
- SS.flush();
return Mangled;
}
@@ -37,7 +36,6 @@ static std::string mangleFunc(StringRef IRName,
std::string Mangled;
raw_string_ostream SS(Mangled);
Mang.getNameWithPrefix(SS, F, false);
- SS.flush();
F->eraseFromParent();
return Mangled;
}
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index e9bf367ac945b3..e99893498dde58 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -299,7 +299,6 @@ TEST_F(MDNodeTest, Print) {
std::string Actual_; \
raw_string_ostream OS(Actual_); \
PRINT; \
- OS.flush(); \
std::string Expected_(EXPECTED); \
EXPECT_EQ(Expected_, Actual_); \
} while (false)
diff --git a/llvm/unittests/IR/ModuleSummaryIndexTest.cpp b/llvm/unittests/IR/ModuleSummaryIndexTest.cpp
index f716a04ad3dcc9..aa136af882054c 100644
--- a/llvm/unittests/IR/ModuleSummaryIndexTest.cpp
+++ b/llvm/unittests/IR/ModuleSummaryIndexTest.cpp
@@ -45,7 +45,6 @@ TEST(ModuleSummaryIndexTest, MemProfSummaryPrinting) {
for (auto &AI : AllocSummary->allocs())
OS << "\n" << AI;
- OS.flush();
EXPECT_EQ(Data, R"(
Callee: 23 Clones: 0 StackIds: 2, 3
Callee: 23 Clones: 0 StackIds: 2, 4
diff --git a/llvm/unittests/MC/MCInstPrinter.cpp b/llvm/unittests/MC/MCInstPrinter.cpp
index bff58c46edb8c3..9002045d539f4b 100644
--- a/llvm/unittests/MC/MCInstPrinter.cpp
+++ b/llvm/unittests/MC/MCInstPrinter.cpp
@@ -53,7 +53,6 @@ class MCInstPrinterTest : public ::testing::Test {
std::string Buffer;
raw_string_ostream OS(Buffer);
OS << Printer->formatHex(i);
- OS.flush();
return Buffer;
}
};
diff --git a/llvm/unittests/MIR/MachineMetadata.cpp b/llvm/unittests/MIR/MachineMetadata.cpp
index cd30768f7ce766..ac1397f4ba6452 100644
--- a/llvm/unittests/MIR/MachineMetadata.cpp
+++ b/llvm/unittests/MIR/MachineMetadata.cpp
@@ -106,7 +106,6 @@ static std::string print(std::function<void(raw_ostream &OS)> PrintFn) {
std::string Str;
raw_string_ostream OS(Str);
PrintFn(OS);
- OS.flush();
return Str;
}
diff --git a/llvm/unittests/Object/SymbolicFileTest.cpp b/llvm/unittests/Object/SymbolicFileTest.cpp
index 8308a0014f20ba..38875ce7b8cd99 100644
--- a/llvm/unittests/Object/SymbolicFileTest.cpp
+++ b/llvm/unittests/Object/SymbolicFileTest.cpp
@@ -35,7 +35,6 @@ TEST(Object, DataRefImplOstream) {
}
OS << Data;
- OS.flush();
EXPECT_EQ(Expected, s);
}
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index 259d6ffba2aba8..c252252b31a94a 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -431,7 +431,6 @@ MATCHER_P(EqualsRecord, Want, "") {
Want.print(OS);
OS << "Got:\n";
Got.print(OS);
- OS.flush();
*result_listener << "MemProf Record
diff ers!\n" << Buffer;
return false;
};
diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index 14623e180f6c85..b7a9170642f2ba 100644
--- a/llvm/unittests/ProfileData/MemProfTest.cpp
+++ b/llvm/unittests/ProfileData/MemProfTest.cpp
@@ -255,7 +255,6 @@ TEST(MemProf, PortableWrapper) {
std::string Buffer;
llvm::raw_string_ostream OS(Buffer);
WriteBlock.serialize(Schema, OS);
- OS.flush();
PortableMemInfoBlock ReadBlock(
Schema, reinterpret_cast<const unsigned char *>(Buffer.data()));
@@ -296,7 +295,6 @@ TEST(MemProf, RecordSerializationRoundTripVersion0And1) {
std::string Buffer;
llvm::raw_string_ostream OS(Buffer);
Record.serialize(Schema, OS, llvm::memprof::Version0);
- OS.flush();
const IndexedMemProfRecord GotRecord = IndexedMemProfRecord::deserialize(
Schema, reinterpret_cast<const unsigned char *>(Buffer.data()),
@@ -326,7 +324,6 @@ TEST(MemProf, RecordSerializationRoundTripVerion2) {
std::string Buffer;
llvm::raw_string_ostream OS(Buffer);
Record.serialize(Schema, OS, llvm::memprof::Version2);
- OS.flush();
const IndexedMemProfRecord GotRecord = IndexedMemProfRecord::deserialize(
Schema, reinterpret_cast<const unsigned char *>(Buffer.data()),
@@ -378,7 +375,6 @@ TEST(MemProf, RecordSerializationRoundTripVersion2HotColdSchema) {
std::string Buffer;
llvm::raw_string_ostream OS(Buffer);
Record.serialize(Schema, OS, llvm::memprof::Version2);
- OS.flush();
const IndexedMemProfRecord GotRecord = IndexedMemProfRecord::deserialize(
Schema, reinterpret_cast<const unsigned char *>(Buffer.data()),
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index 23f6081cd32a45..3df4107ebf4399 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -520,7 +520,6 @@ TEST(CommandLineTest, LookupFailsInWrongSubCommand) {
const char *args[] = {"prog", "sc1", "-sc2"};
EXPECT_FALSE(cl::ParseCommandLineOptions(3, args, StringRef(), &OS));
- OS.flush();
EXPECT_FALSE(Errs.empty());
}
@@ -616,7 +615,6 @@ TEST(CommandLineTest, AddToAllSubCommands) {
EXPECT_TRUE(AllOpt);
// Since all parsing succeeded, the error message should be empty.
- OS.flush();
EXPECT_TRUE(Errs.empty());
}
@@ -657,14 +655,12 @@ TEST(CommandLineTest, RemoveFromRegularSubCommand) {
EXPECT_FALSE(RemoveOption);
EXPECT_TRUE(cl::ParseCommandLineOptions(3, args, StringRef(), &OS));
EXPECT_TRUE(RemoveOption);
- OS.flush();
EXPECT_TRUE(Errs.empty());
RemoveOption.removeArgument();
cl::ResetAllOptionOccurrences();
EXPECT_FALSE(cl::ParseCommandLineOptions(3, args, StringRef(), &OS));
- OS.flush();
EXPECT_FALSE(Errs.empty());
}
@@ -1277,15 +1273,15 @@ TEST(CommandLineTest, PositionalEatArgsError) {
std::string Errs;
raw_string_ostream OS(Errs);
- EXPECT_FALSE(cl::ParseCommandLineOptions(2, args, StringRef(), &OS)); OS.flush();
+ EXPECT_FALSE(cl::ParseCommandLineOptions(2, args, StringRef(), &OS));
EXPECT_FALSE(Errs.empty()); Errs.clear();
- EXPECT_FALSE(cl::ParseCommandLineOptions(3, args2, StringRef(), &OS)); OS.flush();
+ EXPECT_FALSE(cl::ParseCommandLineOptions(3, args2, StringRef(), &OS));
EXPECT_FALSE(Errs.empty()); Errs.clear();
- EXPECT_TRUE(cl::ParseCommandLineOptions(3, args3, StringRef(), &OS)); OS.flush();
+ EXPECT_TRUE(cl::ParseCommandLineOptions(3, args3, StringRef(), &OS));
EXPECT_TRUE(Errs.empty()); Errs.clear();
cl::ResetAllOptionOccurrences();
- EXPECT_TRUE(cl::ParseCommandLineOptions(6, args4, StringRef(), &OS)); OS.flush();
+ EXPECT_TRUE(cl::ParseCommandLineOptions(6, args4, StringRef(), &OS));
EXPECT_EQ(PosEatArgs.size(), 1u);
EXPECT_EQ(PosEatArgs2.size(), 2u);
EXPECT_TRUE(Errs.empty());
@@ -1875,7 +1871,7 @@ TEST(CommandLineTest, LongOptions) {
//
EXPECT_TRUE(
- cl::ParseCommandLineOptions(4, args1, StringRef(), &OS)); OS.flush();
+ cl::ParseCommandLineOptions(4, args1, StringRef(), &OS));
EXPECT_TRUE(OptA);
EXPECT_FALSE(OptBLong);
EXPECT_STREQ("val1", OptAB.c_str());
@@ -1883,7 +1879,7 @@ TEST(CommandLineTest, LongOptions) {
cl::ResetAllOptionOccurrences();
EXPECT_TRUE(
- cl::ParseCommandLineOptions(4, args2, StringRef(), &OS)); OS.flush();
+ cl::ParseCommandLineOptions(4, args2, StringRef(), &OS));
EXPECT_TRUE(OptA);
EXPECT_FALSE(OptBLong);
EXPECT_STREQ("val1", OptAB.c_str());
@@ -1893,7 +1889,7 @@ TEST(CommandLineTest, LongOptions) {
// Fails because `-ab` and `--ab` are treated the same and appear more than
// once. Also, `val1` is unexpected.
EXPECT_FALSE(
- cl::ParseCommandLineOptions(4, args3, StringRef(), &OS)); OS.flush();
+ cl::ParseCommandLineOptions(4, args3, StringRef(), &OS));
outs()<< Errs << "\n";
EXPECT_FALSE(Errs.empty()); Errs.clear();
cl::ResetAllOptionOccurrences();
@@ -1906,13 +1902,13 @@ TEST(CommandLineTest, LongOptions) {
// Fails because `-ab` is treated as `-a -b`, so `-a` is seen twice, and
// `val1` is unexpected.
EXPECT_FALSE(cl::ParseCommandLineOptions(4, args1, StringRef(),
- &OS, nullptr, true)); OS.flush();
+ &OS, nullptr, true));
EXPECT_FALSE(Errs.empty()); Errs.clear();
cl::ResetAllOptionOccurrences();
// Works because `-a` is treated
diff erently than `--ab`.
EXPECT_TRUE(cl::ParseCommandLineOptions(4, args2, StringRef(),
- &OS, nullptr, true)); OS.flush();
+ &OS, nullptr, true));
EXPECT_TRUE(Errs.empty()); Errs.clear();
cl::ResetAllOptionOccurrences();
@@ -1922,7 +1918,6 @@ TEST(CommandLineTest, LongOptions) {
EXPECT_TRUE(OptA);
EXPECT_TRUE(OptBLong);
EXPECT_STREQ("val1", OptAB.c_str());
- OS.flush();
EXPECT_TRUE(Errs.empty()); Errs.clear();
cl::ResetAllOptionOccurrences();
}
@@ -1941,12 +1936,10 @@ TEST(CommandLineTest, OptionErrorMessage) {
raw_string_ostream OS(Errs);
OptA.error("custom error", OS);
- OS.flush();
EXPECT_NE(Errs.find("for the -a option:"), std::string::npos);
Errs.clear();
OptLong.error("custom error", OS);
- OS.flush();
EXPECT_NE(Errs.find("for the --long option:"), std::string::npos);
Errs.clear();
@@ -1969,7 +1962,6 @@ TEST(CommandLineTest, OptionErrorMessageSuggest) {
raw_string_ostream OS(Errs);
EXPECT_FALSE(cl::ParseCommandLineOptions(2, args, StringRef(), &OS));
- OS.flush();
EXPECT_NE(Errs.find("prog: Did you mean '--aluminium'?\n"),
std::string::npos);
Errs.clear();
@@ -1992,7 +1984,6 @@ TEST(CommandLineTest, OptionErrorMessageSuggestNoHidden) {
raw_string_ostream OS(Errs);
EXPECT_FALSE(cl::ParseCommandLineOptions(2, args, StringRef(), &OS));
- OS.flush();
EXPECT_NE(Errs.find("prog: Did you mean '--aluminium'?\n"),
std::string::npos);
Errs.clear();
@@ -2082,7 +2073,6 @@ TEST(CommandLineTest, ConsumeAfterOnePositional) {
std::string Errs;
raw_string_ostream OS(Errs);
EXPECT_TRUE(cl::ParseCommandLineOptions(4, Args, StringRef(), &OS));
- OS.flush();
EXPECT_EQ("input", Input);
EXPECT_EQ(ExtraArgs.size(), 2u);
EXPECT_EQ(ExtraArgs[0], "arg1");
@@ -2105,7 +2095,6 @@ TEST(CommandLineTest, ConsumeAfterTwoPositionals) {
std::string Errs;
raw_string_ostream OS(Errs);
EXPECT_TRUE(cl::ParseCommandLineOptions(5, Args, StringRef(), &OS));
- OS.flush();
EXPECT_EQ("input1", Input1);
EXPECT_EQ("input2", Input2);
EXPECT_EQ(ExtraArgs.size(), 2u);
diff --git a/llvm/unittests/Support/CrashRecoveryTest.cpp b/llvm/unittests/Support/CrashRecoveryTest.cpp
index 4026300d719114..a22e532ec4c831 100644
--- a/llvm/unittests/Support/CrashRecoveryTest.cpp
+++ b/llvm/unittests/Support/CrashRecoveryTest.cpp
@@ -111,8 +111,7 @@ TEST(CrashRecoveryTest, LimitedStackTrace) {
std::string Res;
llvm::raw_string_ostream RawStream(Res);
PrintStackTrace(RawStream, 1);
- std::string Str = RawStream.str();
- EXPECT_EQ(std::string::npos, Str.find("#1"));
+ EXPECT_EQ(std::string::npos, Res.find("#1"));
}
#ifdef _WIN32
diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp
index 16e4865e1bfe97..98d19e8d2a15a3 100644
--- a/llvm/unittests/Support/ErrorTest.cpp
+++ b/llvm/unittests/Support/ErrorTest.cpp
@@ -460,13 +460,11 @@ TEST(Error, createStringError) {
EXPECT_EQ(Msg, "foobar10xff\n")
<< "Unexpected createStringError() log result";
- S.flush();
Msg.clear();
logAllUnhandledErrors(createStringError(EC, Bar), S);
EXPECT_EQ(Msg, "bar\n")
<< "Unexpected createStringError() (overloaded) log result";
- S.flush();
Msg.clear();
auto Res = errorToErrorCode(createStringError(EC, "foo%s", Bar));
EXPECT_EQ(Res, EC)
diff --git a/llvm/unittests/Support/FormatVariadicTest.cpp b/llvm/unittests/Support/FormatVariadicTest.cpp
index 68938480ecfe20..8e326e1f2b4396 100644
--- a/llvm/unittests/Support/FormatVariadicTest.cpp
+++ b/llvm/unittests/Support/FormatVariadicTest.cpp
@@ -585,7 +585,6 @@ TEST(FormatVariadicTest, BigTest) {
for (auto &Item : Ts) {
Stream << std::apply(format_tuple(Line), Item) << "\n";
}
- Stream.flush();
const char *Expected =
R"foo(There are {14} items in the tuple, and {2} tuple(s) in the array.
Char| HexInt| Str | Ref | std::str | double| float| pointer|comma | exp| bigint| bigint2| limit|byte
diff --git a/llvm/unittests/Support/LEB128Test.cpp b/llvm/unittests/Support/LEB128Test.cpp
index 5aa7139c45a7ad..0c54a2846903bf 100644
--- a/llvm/unittests/Support/LEB128Test.cpp
+++ b/llvm/unittests/Support/LEB128Test.cpp
@@ -24,7 +24,6 @@ TEST(LEB128Test, EncodeSLEB128) {
std::string Actual1; \
raw_string_ostream Stream(Actual1); \
encodeSLEB128(VALUE, Stream, PAD); \
- Stream.flush(); \
EXPECT_EQ(Expected, Actual1); \
\
/* encodeSLEB128(uint64_t, uint8_t *, unsigned) */ \
@@ -69,7 +68,6 @@ TEST(LEB128Test, EncodeULEB128) {
std::string Actual1; \
raw_string_ostream Stream(Actual1); \
encodeULEB128(VALUE, Stream, PAD); \
- Stream.flush(); \
EXPECT_EQ(Expected, Actual1); \
\
/* encodeULEB128(uint64_t, uint8_t *, unsigned) */ \
diff --git a/llvm/unittests/Support/ModRefTest.cpp b/llvm/unittests/Support/ModRefTest.cpp
index 5ebb5f6a41a586..35107e50b32db7 100644
--- a/llvm/unittests/Support/ModRefTest.cpp
+++ b/llvm/unittests/Support/ModRefTest.cpp
@@ -21,7 +21,6 @@ TEST(ModRefTest, PrintMemoryEffects) {
std::string S;
raw_string_ostream OS(S);
OS << MemoryEffects::none();
- OS.flush();
EXPECT_EQ(S, "ArgMem: NoModRef, InaccessibleMem: NoModRef, Other: NoModRef");
}
diff --git a/llvm/unittests/Support/NativeFormatTests.cpp b/llvm/unittests/Support/NativeFormatTests.cpp
index 11753068b0fa2c..ac04c5a53d74a1 100644
--- a/llvm/unittests/Support/NativeFormatTests.cpp
+++ b/llvm/unittests/Support/NativeFormatTests.cpp
@@ -20,7 +20,6 @@ template <typename T> std::string format_number(T N, IntegerStyle Style) {
std::string S;
llvm::raw_string_ostream Str(S);
write_integer(Str, N, 0, Style);
- Str.flush();
return S;
}
@@ -29,7 +28,6 @@ std::string format_number(uint64_t N, HexPrintStyle Style,
std::string S;
llvm::raw_string_ostream Str(S);
write_hex(Str, N, Style, Width);
- Str.flush();
return S;
}
@@ -38,7 +36,6 @@ std::string format_number(double D, FloatStyle Style,
std::string S;
llvm::raw_string_ostream Str(S);
write_double(Str, D, Style, Precision);
- Str.flush();
return S;
}
diff --git a/llvm/unittests/Support/RISCVAttributeParserTest.cpp b/llvm/unittests/Support/RISCVAttributeParserTest.cpp
index 498f58e98b29d6..aa73bb92d6e3ed 100644
--- a/llvm/unittests/Support/RISCVAttributeParserTest.cpp
+++ b/llvm/unittests/Support/RISCVAttributeParserTest.cpp
@@ -38,8 +38,8 @@ static bool testAttribute(unsigned Tag, unsigned Value, unsigned ExpectedTag,
raw_string_ostream OS(buffer);
RISCVAttributeSection Section(Tag, Value);
Section.write(OS);
- ArrayRef<uint8_t> Bytes(reinterpret_cast<const uint8_t *>(OS.str().c_str()),
- OS.str().size());
+ ArrayRef<uint8_t> Bytes(reinterpret_cast<const uint8_t *>(buffer.c_str()),
+ buffer.size());
RISCVAttributeParser Parser;
cantFail(Parser.parse(Bytes, llvm::endianness::little));
diff --git a/llvm/unittests/Support/SourceMgrTest.cpp b/llvm/unittests/Support/SourceMgrTest.cpp
index 75a0cfe35aaf0e..f5366a79c793ef 100644
--- a/llvm/unittests/Support/SourceMgrTest.cpp
+++ b/llvm/unittests/Support/SourceMgrTest.cpp
@@ -537,7 +537,6 @@ TEST_F(SourceMgrTest, PrintWithoutLoc) {
auto Diag =
llvm::SMDiagnostic("file.in", llvm::SourceMgr::DK_Error, "message");
Diag.print(nullptr, OS);
- OS.flush();
EXPECT_EQ("file.in: error: message\n", Output);
Output.clear();
Diag.print(nullptr, OS, false, false, false);
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp
index 8d1eb6969270f6..eb590e474c2ecc 100644
--- a/llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -2927,7 +2927,6 @@ TEST_F(VFSFromYAMLTest, YAMLVFSWriterTest) {
std::string Buffer;
raw_string_ostream OS(Buffer);
VFSWriter.write(OS);
- OS.flush();
IntrusiveRefCntPtr<ErrorDummyFileSystem> Lower(new ErrorDummyFileSystem());
Lower->addDirectory("//root/");
@@ -2978,7 +2977,6 @@ TEST_F(VFSFromYAMLTest, YAMLVFSWriterTest2) {
std::string Buffer;
raw_string_ostream OS(Buffer);
VFSWriter.write(OS);
- OS.flush();
IntrusiveRefCntPtr<ErrorDummyFileSystem> Lower(new ErrorDummyFileSystem());
IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLRawString(Buffer, Lower);
@@ -3011,7 +3009,6 @@ TEST_F(VFSFromYAMLTest, YAMLVFSWriterTest3) {
std::string Buffer;
raw_string_ostream OS(Buffer);
VFSWriter.write(OS);
- OS.flush();
IntrusiveRefCntPtr<ErrorDummyFileSystem> Lower(new ErrorDummyFileSystem());
IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLRawString(Buffer, Lower);
@@ -3032,7 +3029,6 @@ TEST_F(VFSFromYAMLTest, YAMLVFSWriterTestHandleDirs) {
std::string Buffer;
raw_string_ostream OS(Buffer);
VFSWriter.write(OS);
- OS.flush();
// We didn't add a single file - only directories.
EXPECT_EQ(Buffer.find("'type': 'file'"), std::string::npos);
diff --git a/llvm/unittests/Support/YAMLIOTest.cpp b/llvm/unittests/Support/YAMLIOTest.cpp
index 69537fc36a8531..e10fe099a30adb 100644
--- a/llvm/unittests/Support/YAMLIOTest.cpp
+++ b/llvm/unittests/Support/YAMLIOTest.cpp
@@ -1378,7 +1378,6 @@ TEST(YAMLIO, TestReadWriteMyFlowSequence) {
yout << map;
// Verify sequences were written in flow style
- ostr.flush();
llvm::StringRef flowOut(intermediate);
EXPECT_NE(llvm::StringRef::npos, flowOut.find("one, two"));
EXPECT_NE(llvm::StringRef::npos, flowOut.find("10, -30, 1024"));
@@ -1424,7 +1423,6 @@ TEST(YAMLIO, TestReadWriteSequenceOfMyFlowSequence) {
// Verify sequences were written in flow style
// and that the parent sequence used '-'.
- ostr.flush();
llvm::StringRef flowOut(intermediate);
EXPECT_NE(llvm::StringRef::npos, flowOut.find("- [ 0 ]"));
EXPECT_NE(llvm::StringRef::npos, flowOut.find("- [ 12, 1, -512 ]"));
@@ -1935,7 +1933,6 @@ TEST(YAMLIO, TestReadWriteMyFlowMapping) {
yout << doc;
// Verify that mappings were written in flow style
- ostr.flush();
llvm::StringRef flowOut(intermediate);
EXPECT_NE(llvm::StringRef::npos, flowOut.find("{ foo: 42, bar: 907 }"));
EXPECT_NE(llvm::StringRef::npos, flowOut.find("- { foo: 1, bar: 2 }"));
@@ -2538,7 +2535,6 @@ TEST(YAMLIO, TestWrapFlow) {
Output yout(ostr, nullptr, 15);
yout << Map;
- ostr.flush();
EXPECT_EQ(out,
"---\n"
"{ str1: This is str1, \n"
@@ -2548,7 +2544,6 @@ TEST(YAMLIO, TestWrapFlow) {
out.clear();
yout << Seq;
- ostr.flush();
EXPECT_EQ(out,
"---\n"
"[ This is str1, \n"
@@ -2562,7 +2557,6 @@ TEST(YAMLIO, TestWrapFlow) {
Output yout(ostr, nullptr, 25);
yout << Map;
- ostr.flush();
EXPECT_EQ(out,
"---\n"
"{ str1: This is str1, str2: This is str2, \n"
@@ -2571,7 +2565,6 @@ TEST(YAMLIO, TestWrapFlow) {
out.clear();
yout << Seq;
- ostr.flush();
EXPECT_EQ(out,
"---\n"
"[ This is str1, This is str2, \n"
@@ -2584,7 +2577,6 @@ TEST(YAMLIO, TestWrapFlow) {
Output yout(ostr, nullptr, 0);
yout << Map;
- ostr.flush();
EXPECT_EQ(out,
"---\n"
"{ str1: This is str1, str2: This is str2, str3: This is str3 }\n"
@@ -2592,7 +2584,6 @@ TEST(YAMLIO, TestWrapFlow) {
out.clear();
yout << Seq;
- ostr.flush();
EXPECT_EQ(out,
"---\n"
"[ This is str1, This is str2, This is str3 ]\n"
@@ -2646,7 +2637,6 @@ TEST(YAMLIO, TestMapWithContext) {
Output yout(ostr, nullptr, 15);
yout << Nested;
- ostr.flush();
EXPECT_EQ(1, Context.A);
EXPECT_EQ("---\n"
"Simple:\n"
@@ -2661,7 +2651,6 @@ TEST(YAMLIO, TestMapWithContext) {
Nested.Simple.B = 2;
Nested.Simple.C = 3;
yout << Nested;
- ostr.flush();
EXPECT_EQ(2, Context.A);
EXPECT_EQ("---\n"
"Simple:\n"
@@ -2683,7 +2672,6 @@ TEST(YAMLIO, TestCustomMapping) {
Output xout(ostr, nullptr, 0);
xout << x;
- ostr.flush();
EXPECT_EQ("---\n"
"{}\n"
"...\n",
@@ -2694,7 +2682,6 @@ TEST(YAMLIO, TestCustomMapping) {
out.clear();
xout << x;
- ostr.flush();
EXPECT_EQ("---\n"
"bar: 2\n"
"foo: 1\n"
@@ -2723,7 +2710,6 @@ TEST(YAMLIO, TestCustomMappingStruct) {
Output xout(ostr, nullptr, 0);
xout << x;
- ostr.flush();
EXPECT_EQ("---\n"
"bar:\n"
" foo: 3\n"
@@ -2795,8 +2781,6 @@ static void TestEscaped(llvm::StringRef Input, llvm::StringRef Expected) {
llvm::yaml::EmptyContext Ctx;
yamlize(xout, Input, true, Ctx);
- ostr.flush();
-
// Make a separate StringRef so we get nice byte-by-byte output.
llvm::StringRef Got(out);
EXPECT_EQ(Expected, Got);
diff --git a/llvm/unittests/Target/RISCV/RISCVInstrInfoTest.cpp b/llvm/unittests/Target/RISCV/RISCVInstrInfoTest.cpp
index cc0aca10fc6da9..820918f811a349 100644
--- a/llvm/unittests/Target/RISCV/RISCVInstrInfoTest.cpp
+++ b/llvm/unittests/Target/RISCV/RISCVInstrInfoTest.cpp
@@ -243,8 +243,7 @@ static void expectDIEPrintResult(const DIExpression *Expr, StringRef Expected) {
std::string Output;
raw_string_ostream OS(Output);
Expr->print(OS);
- OS.flush();
- EXPECT_EQ(OS.str(), Expected);
+ EXPECT_EQ(Output, Expected);
}
TEST_P(RISCVInstrInfoTest, DescribeLoadedValue) {
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
index 9cf9060458bc98..a7ff51067c8d03 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -705,7 +705,6 @@ TEST(VPBasicBlockTest, print) {
raw_string_ostream OS(I3Dump);
VPSlotTracker SlotTracker;
I3->print(OS, "", SlotTracker);
- OS.flush();
EXPECT_EQ("EMIT br <badref>, <badref>", I3Dump);
}
@@ -769,7 +768,6 @@ No successors
raw_string_ostream OS(I3Dump);
VPSlotTracker SlotTracker(&Plan);
I3->print(OS, "", SlotTracker);
- OS.flush();
EXPECT_EQ("EMIT br vp<%2>, vp<%3>", I3Dump);
}
@@ -777,7 +775,6 @@ No successors
std::string I4Dump;
raw_string_ostream OS(I4Dump);
OS << *I4;
- OS.flush();
EXPECT_EQ("EMIT vp<%5> = mul vp<%3>, vp<%2>", I4Dump);
}
}
diff --git a/llvm/unittests/XRay/FDRProducerConsumerTest.cpp b/llvm/unittests/XRay/FDRProducerConsumerTest.cpp
index ab55e22b0f0ab6..24acb8998b7279 100644
--- a/llvm/unittests/XRay/FDRProducerConsumerTest.cpp
+++ b/llvm/unittests/XRay/FDRProducerConsumerTest.cpp
@@ -127,7 +127,6 @@ TYPED_TEST_P(RoundTripTest, RoundTripsSingleValue) {
ASSERT_FALSE(errorToBool(BE.apply(*this->Writer)));
auto &R = this->Rec;
ASSERT_FALSE(errorToBool(R->apply(*this->Writer)));
- this->OS.flush();
DataExtractor DE(this->Data, sys::IsLittleEndianHost, 8);
uint64_t OffsetPtr = 0;
@@ -151,7 +150,6 @@ TYPED_TEST_P(RoundTripTest, RoundTripsSingleValue) {
FDRTraceWriter Writer2(OS2, this->H);
for (auto &P : Records)
ASSERT_FALSE(errorToBool(P->apply(Writer2)));
- OS2.flush();
EXPECT_EQ(Data2.substr(sizeof(XRayFileHeader)),
this->Data.substr(sizeof(XRayFileHeader)));
@@ -168,7 +166,6 @@ TYPED_TEST_P(RoundTripTestV5, RoundTripsSingleValue) {
ASSERT_FALSE(errorToBool(BE.apply(*this->Writer)));
auto &R = this->Rec;
ASSERT_FALSE(errorToBool(R->apply(*this->Writer)));
- this->OS.flush();
DataExtractor DE(this->Data, sys::IsLittleEndianHost, 8);
uint64_t OffsetPtr = 0;
@@ -192,7 +189,6 @@ TYPED_TEST_P(RoundTripTestV5, RoundTripsSingleValue) {
FDRTraceWriter Writer2(OS2, this->H);
for (auto &P : Records)
ASSERT_FALSE(errorToBool(P->apply(Writer2)));
- OS2.flush();
EXPECT_EQ(Data2.substr(sizeof(XRayFileHeader)),
this->Data.substr(sizeof(XRayFileHeader)));
diff --git a/llvm/unittests/XRay/FDRRecordPrinterTest.cpp b/llvm/unittests/XRay/FDRRecordPrinterTest.cpp
index a29112f899e1f8..19ce21cbda9d31 100644
--- a/llvm/unittests/XRay/FDRRecordPrinterTest.cpp
+++ b/llvm/unittests/XRay/FDRRecordPrinterTest.cpp
@@ -112,7 +112,6 @@ TYPED_TEST_SUITE_P(PrinterTest);
TYPED_TEST_P(PrinterTest, PrintsRecord) {
ASSERT_NE(nullptr, this->R);
ASSERT_FALSE(errorToBool(this->R->apply(this->P)));
- this->OS.flush();
EXPECT_THAT(this->Data, Eq(Helper<TypeParam>::expected()));
}
@@ -130,7 +129,6 @@ TEST(FDRRecordPrinterTest, WriteFunctionRecordEnter) {
RecordPrinter P(OS);
FunctionRecord R(RecordTypes::ENTER, 1, 2);
ASSERT_FALSE(errorToBool(R.apply(P)));
- OS.flush();
EXPECT_THAT(Data, Eq("<Function Enter: #1 delta = +2>"));
}
@@ -140,7 +138,6 @@ TEST(FDRRecordPrinterTest, WriteFunctionRecordExit) {
RecordPrinter P(OS);
FunctionRecord R(RecordTypes::EXIT, 1, 2);
ASSERT_FALSE(errorToBool(R.apply(P)));
- OS.flush();
EXPECT_THAT(Data, Eq("<Function Exit: #1 delta = +2>"));
}
@@ -150,7 +147,6 @@ TEST(FDRRecordPrinterTest, WriteFunctionRecordTailExit) {
RecordPrinter P(OS);
FunctionRecord R(RecordTypes::TAIL_EXIT, 1, 2);
ASSERT_FALSE(errorToBool(R.apply(P)));
- OS.flush();
EXPECT_THAT(Data, Eq("<Function Tail Exit: #1 delta = +2>"));
}
@@ -160,7 +156,6 @@ TEST(FDRRecordPrinterTest, WriteFunctionRecordEnterArg) {
RecordPrinter P(OS);
FunctionRecord R(RecordTypes::ENTER_ARG, 1, 2);
ASSERT_FALSE(errorToBool(R.apply(P)));
- OS.flush();
EXPECT_THAT(Data, Eq("<Function Enter With Arg: #1 delta = +2>"));
}
diff --git a/llvm/unittests/XRay/FDRRecordsTest.cpp b/llvm/unittests/XRay/FDRRecordsTest.cpp
index aac3c86e49e0f8..e231bf560ef177 100644
--- a/llvm/unittests/XRay/FDRRecordsTest.cpp
+++ b/llvm/unittests/XRay/FDRRecordsTest.cpp
@@ -158,7 +158,6 @@ TEST(XRayFDRTest, IndexAndVerifyBlocks) {
}
}
- OS.flush();
EXPECT_THAT(Output, Not(Eq("")));
}
diff --git a/llvm/unittests/XRay/FDRTraceWriterTest.cpp b/llvm/unittests/XRay/FDRTraceWriterTest.cpp
index 4f2f06e468c68f..32c75e440a40e0 100644
--- a/llvm/unittests/XRay/FDRTraceWriterTest.cpp
+++ b/llvm/unittests/XRay/FDRTraceWriterTest.cpp
@@ -52,7 +52,6 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion3) {
.consume();
for (auto &P : L)
ASSERT_FALSE(errorToBool(P->apply(Writer)));
- OS.flush();
// Then from here we load the Trace file.
DataExtractor DE(Data, sys::IsLittleEndianHost, 8);
@@ -97,7 +96,6 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion2) {
.consume();
for (auto &P : L)
ASSERT_FALSE(errorToBool(P->apply(Writer)));
- OS.flush();
// Then from here we load the Trace file.
DataExtractor DE(Data, sys::IsLittleEndianHost, 8);
@@ -134,7 +132,6 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion1) {
std::memcpy(H.FreeFormData, reinterpret_cast<const char *>(&BufferSize),
sizeof(BufferSize));
FDRTraceWriter Writer(OS, H);
- OS.flush();
// Ensure that at this point the Data buffer has the file header serialized
// size.
@@ -152,7 +149,6 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion1) {
// We need to pad the buffer with 4016 (4096 - 80) bytes of zeros.
OS.write_zeros(4016);
- OS.flush();
// For version 1 of the log, we need the whole buffer to be the size of the
// file header plus 32.
diff --git a/llvm/unittests/tools/llvm-exegesis/ProgressMeterTest.cpp b/llvm/unittests/tools/llvm-exegesis/ProgressMeterTest.cpp
index 0b06499c865599..58cc530404c85f 100644
--- a/llvm/unittests/tools/llvm-exegesis/ProgressMeterTest.cpp
+++ b/llvm/unittests/tools/llvm-exegesis/ProgressMeterTest.cpp
@@ -47,7 +47,6 @@ TEST(ProgressMeterTest, Integration) {
ProgressMeter<PreprogrammedClock> m(5, SS);
for (int i = 0; i != 5; ++i)
decltype(m)::ProgressMeterStep s(&m);
- SS.flush();
ASSERT_EQ("Processing... 20%, ETA 00:20\n"
"Processing... 40%, ETA 00:29\n"
"Processing... 60%, ETA 00:23\n"
More information about the llvm-commits
mailing list