aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Support')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp29
-rw-r--r--llvm/unittests/Support/CrashRecoveryTest.cpp3
-rw-r--r--llvm/unittests/Support/ErrorTest.cpp2
-rw-r--r--llvm/unittests/Support/FormatVariadicTest.cpp1
-rw-r--r--llvm/unittests/Support/LEB128Test.cpp2
-rw-r--r--llvm/unittests/Support/ModRefTest.cpp1
-rw-r--r--llvm/unittests/Support/NativeFormatTests.cpp3
-rw-r--r--llvm/unittests/Support/RISCVAttributeParserTest.cpp4
-rw-r--r--llvm/unittests/Support/SourceMgrTest.cpp1
-rw-r--r--llvm/unittests/Support/VirtualFileSystemTest.cpp4
-rw-r--r--llvm/unittests/Support/YAMLIOTest.cpp16
11 files changed, 12 insertions, 54 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index 23f6081..3df4107 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 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);
diff --git a/llvm/unittests/Support/CrashRecoveryTest.cpp b/llvm/unittests/Support/CrashRecoveryTest.cpp
index 4026300..a22e532 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 16e4865..98d19e8 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 6893848..8e326e1 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 5aa7139..0c54a28 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 5ebb5f6..35107e5 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 1175306..ac04c5a 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 498f58e..aa73bb9 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 75a0cfe..f5366a7 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 8d1eb69..eb590e4 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 69537fc..e10fe09 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);