Skip to content

Commit 459a82e

Browse files
committed
[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()
1 parent c010b72 commit 459a82e

32 files changed

+13
-101
lines changed

llvm/unittests/ADT/RewriteBufferTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ static std::string writeOutput(const RewriteBuffer &Buf) {
1919
std::string Result;
2020
raw_string_ostream OS(Result);
2121
Buf.write(OS);
22-
OS.flush();
2322
return Result;
2423
}
2524

llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ void expectDumpResult(const dwarf::CIE &TestCIE, bool IsEH,
4444
auto DumpOpts = DIDumpOptions();
4545
DumpOpts.IsEH = IsEH;
4646
TestCIE.dump(OS, DumpOpts);
47-
OS.flush();
4847
StringRef FirstLine = StringRef(Output).split('\n').first;
4948
EXPECT_EQ(FirstLine, ExpectedFirstLine);
5049
}
@@ -56,7 +55,6 @@ void expectDumpResult(const dwarf::FDE &TestFDE, bool IsEH,
5655
auto DumpOpts = DIDumpOptions();
5756
DumpOpts.IsEH = IsEH;
5857
TestFDE.dump(OS, DumpOpts);
59-
OS.flush();
6058
StringRef FirstLine = StringRef(Output).split('\n').first;
6159
EXPECT_EQ(FirstLine, ExpectedFirstLine);
6260
}
@@ -344,7 +342,6 @@ void expectDumpResult(const dwarf::UnwindLocation &Loc,
344342
std::string Output;
345343
raw_string_ostream OS(Output);
346344
OS << Loc;
347-
OS.flush();
348345
StringRef FirstLine = StringRef(Output).split('\n').first;
349346
EXPECT_EQ(FirstLine, ExpectedFirstLine);
350347
}
@@ -387,7 +384,6 @@ void expectDumpResult(const dwarf::RegisterLocations &Locs,
387384
std::string Output;
388385
raw_string_ostream OS(Output);
389386
OS << Locs;
390-
OS.flush();
391387
StringRef FirstLine = StringRef(Output).split('\n').first;
392388
EXPECT_EQ(FirstLine, ExpectedFirstLine);
393389
}

llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,6 @@ TEST_F(DebugLineBasicFixture, VerboseOutput) {
15581558
raw_string_ostream OS(Output);
15591559
Parser.parseNext(RecordRecoverable, RecordUnrecoverable, &OS,
15601560
/*Verbose=*/true);
1561-
OS.flush();
15621561
StringRef OutputRef(Output);
15631562

15641563
size_t Pos = 0;
@@ -1805,7 +1804,6 @@ struct TruncatedOpcodeFixtureBase : public CommonFixture {
18051804
raw_string_ostream OS(Output);
18061805
Parser.parseNext(RecordRecoverable, RecordUnrecoverable, &OS,
18071806
/*Verbose=*/true);
1808-
OS.flush();
18091807

18101808
std::string LinePrefix =
18111809
("0x0000002f: 0" + Twine::utohexstr(OpcodeValue) + " ").str();

llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ TEST_P(DumpValueFixture, Test) {
375375
Opts.ShowAddresses = true;
376376

377377
Form.dump(OS, Opts);
378-
OS.flush();
379378

380379
EXPECT_EQ(Output, ExpectedResult);
381380
}

llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3802,7 +3802,6 @@ TEST(GSYMTest, TestRangeWarnings) {
38023802
const uint32_t ThreadCount = 1;
38033803
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
38043804
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
3805-
OS.flush();
38063805
SmallString<512> Str;
38073806
raw_svector_ostream OutStrm(Str);
38083807
const auto ByteOrder = llvm::endianness::native;
@@ -4005,7 +4004,6 @@ TEST(GSYMTest, TestEmptyRangeWarnings) {
40054004
const uint32_t ThreadCount = 1;
40064005
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
40074006
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
4008-
OS.flush();
40094007
SmallString<512> Str;
40104008
raw_svector_ostream OutStrm(Str);
40114009
const auto ByteOrder = llvm::endianness::native;
@@ -4158,7 +4156,6 @@ TEST(GSYMTest, TestEmptyLinkageName) {
41584156
const uint32_t ThreadCount = 1;
41594157
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
41604158
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
4161-
OS.flush();
41624159
SmallString<512> Str;
41634160
raw_svector_ostream OutStrm(Str);
41644161
const auto ByteOrder = llvm::endianness::native;
@@ -4320,7 +4317,6 @@ TEST(GSYMTest, TestLineTablesWithEmptyRanges) {
43204317
const uint32_t ThreadCount = 1;
43214318
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
43224319
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
4323-
OS.flush();
43244320
SmallString<512> Str;
43254321
raw_svector_ostream OutStrm(Str);
43264322
const auto ByteOrder = llvm::endianness::native;
@@ -4641,7 +4637,6 @@ TEST(GSYMTest, TestHandlingOfInvalidFileIndexes) {
46414637
const uint32_t ThreadCount = 1;
46424638
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
46434639
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
4644-
OS.flush();
46454640
SmallString<512> Str;
46464641
raw_svector_ostream OutStrm(Str);
46474642
const auto ByteOrder = llvm::endianness::native;
@@ -4857,7 +4852,6 @@ TEST(GSYMTest, TestLookupsOfOverlappingAndUnequalRanges) {
48574852
const uint32_t ThreadCount = 1;
48584853
ASSERT_THAT_ERROR(DT.convert(ThreadCount, OSAgg), Succeeded());
48594854
ASSERT_THAT_ERROR(GC.finalize(OSAgg), Succeeded());
4860-
OS.flush();
48614855
SmallString<512> Str;
48624856
raw_svector_ostream OutStrm(Str);
48634857
const auto ByteOrder = llvm::endianness::native;

llvm/unittests/IR/ConstantsTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ TEST(ConstantsTest, PointerCast) {
172172
Instruction *__I = cast<ConstantExpr>(x)->getAsInstruction(); \
173173
__I->print(__o); \
174174
__I->deleteValue(); \
175-
__o.flush(); \
176175
EXPECT_EQ(std::string(" <badref> = " y), __s); \
177176
}
178177

llvm/unittests/IR/ManglerTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ static std::string mangleStr(StringRef IRName, Mangler &Mang,
2020
std::string Mangled;
2121
raw_string_ostream SS(Mangled);
2222
Mang.getNameWithPrefix(SS, IRName, DL);
23-
SS.flush();
2423
return Mangled;
2524
}
2625

@@ -37,7 +36,6 @@ static std::string mangleFunc(StringRef IRName,
3736
std::string Mangled;
3837
raw_string_ostream SS(Mangled);
3938
Mang.getNameWithPrefix(SS, F, false);
40-
SS.flush();
4139
F->eraseFromParent();
4240
return Mangled;
4341
}

llvm/unittests/IR/MetadataTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ TEST_F(MDNodeTest, Print) {
299299
std::string Actual_; \
300300
raw_string_ostream OS(Actual_); \
301301
PRINT; \
302-
OS.flush(); \
303302
std::string Expected_(EXPECTED); \
304303
EXPECT_EQ(Expected_, Actual_); \
305304
} while (false)

llvm/unittests/IR/ModuleSummaryIndexTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ TEST(ModuleSummaryIndexTest, MemProfSummaryPrinting) {
4545
for (auto &AI : AllocSummary->allocs())
4646
OS << "\n" << AI;
4747

48-
OS.flush();
4948
EXPECT_EQ(Data, R"(
5049
Callee: 23 Clones: 0 StackIds: 2, 3
5150
Callee: 23 Clones: 0 StackIds: 2, 4

llvm/unittests/MC/MCInstPrinter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class MCInstPrinterTest : public ::testing::Test {
5353
std::string Buffer;
5454
raw_string_ostream OS(Buffer);
5555
OS << Printer->formatHex(i);
56-
OS.flush();
5756
return Buffer;
5857
}
5958
};

0 commit comments

Comments
 (0)