[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()
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -375,7 +375,6 @@ TEST_P(DumpValueFixture, Test) {
|
||||
Opts.ShowAddresses = true;
|
||||
|
||||
Form.dump(OS, Opts);
|
||||
OS.flush();
|
||||
|
||||
EXPECT_EQ(Output, ExpectedResult);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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); \
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -53,7 +53,6 @@ public:
|
||||
std::string Buffer;
|
||||
raw_string_ostream OS(Buffer);
|
||||
OS << Printer->formatHex(i);
|
||||
OS.flush();
|
||||
return Buffer;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ TEST(Object, DataRefImplOstream) {
|
||||
}
|
||||
|
||||
OS << Data;
|
||||
OS.flush();
|
||||
|
||||
EXPECT_EQ(Expected, s);
|
||||
}
|
||||
|
||||
@@ -431,7 +431,6 @@ MATCHER_P(EqualsRecord, Want, "") {
|
||||
Want.print(OS);
|
||||
OS << "Got:\n";
|
||||
Got.print(OS);
|
||||
OS.flush();
|
||||
*result_listener << "MemProf Record differs!\n" << Buffer;
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -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()),
|
||||
|
||||
@@ -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 differently 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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) */ \
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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>"));
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,6 @@ TEST(XRayFDRTest, IndexAndVerifyBlocks) {
|
||||
}
|
||||
}
|
||||
|
||||
OS.flush();
|
||||
EXPECT_THAT(Output, Not(Eq("")));
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user