Skip to content

Commit 52b48a7

Browse files
committed
[llvm][unittests] Strip unneeded use of raw_string_ostream::str() (NFC)
Avoid excess layer of indirection.
1 parent 1e3536e commit 52b48a7

File tree

12 files changed

+14
-16
lines changed

12 files changed

+14
-16
lines changed

llvm/unittests/ADT/Interleave.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ TEST(InterleaveTest, Interleave) {
2525
interleave(
2626
Doodles, OS, [&](const char *Name) { OS << Name << "doodle"; }, ", ");
2727

28-
EXPECT_EQ(OS.str(), "goldendoodle, bernadoodle, labradoodle");
28+
EXPECT_EQ(Str, "goldendoodle, bernadoodle, labradoodle");
2929
}
3030

3131
TEST(InterleaveTest, InterleaveComma) {
@@ -36,7 +36,7 @@ TEST(InterleaveTest, InterleaveComma) {
3636
const StringRef LongDogs[] = {"dachshund", "doxie", "dackel", "teckel"};
3737
interleaveComma(LongDogs, OS);
3838

39-
EXPECT_EQ(OS.str(), "dachshund, doxie, dackel, teckel");
39+
EXPECT_EQ(Str, "dachshund, doxie, dackel, teckel");
4040
}
4141

4242
} // anonymous namespace

llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ static void RunRandTest(uint64_t Seed, int Size, int MinCount, int MaxCount,
462462
if (count > 1)
463463
Args.push_back(ConstantInt::get(Type::getInt32Ty(C), value));
464464

465-
OpBundle.push_back(OperandBundleDef{ss.str().c_str(), std::move(Args)});
465+
OpBundle.push_back(OperandBundleDef{str.c_str(), std::move(Args)});
466466
}
467467

468468
auto *Assume = cast<AssumeInst>(CallInst::Create(

llvm/unittests/Analysis/CFGTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class IsPotentiallyReachableTest : public testing::Test {
3939

4040
// A failure here means that the test itself is buggy.
4141
if (!M)
42-
report_fatal_error(os.str().c_str());
42+
report_fatal_error(errMsg.c_str());
4343

4444
Function *F = M->getFunction("test");
4545
if (F == nullptr)

llvm/unittests/Analysis/DXILResourceTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ testing::AssertionResult MDTupleEq(const char *LHSExpr, const char *RHSExpr,
9090
return testing::AssertionFailure() << "Expected equality:\n"
9191
<< " " << LHSExpr << "\n"
9292
<< "Which is:\n"
93-
<< " " << LHSS.str() << "\n\n"
93+
<< " " << LHSRepr << "\n\n"
9494
<< " " << RHSExpr << "\n"
9595
<< "Which is:\n"
96-
<< " " << RHSS.str();
96+
<< " " << RHSRepr;
9797
}
9898
#define EXPECT_MDEQ(X, Y) EXPECT_PRED_FORMAT2(MDTupleEq, X, Y)
9999
} // namespace

llvm/unittests/Analysis/LazyCallGraphTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ std::unique_ptr<Module> parseAssembly(LLVMContext &Context,
3434

3535
// A failure here means that the test itself is buggy.
3636
if (!M)
37-
report_fatal_error(OS.str().c_str());
37+
report_fatal_error(ErrMsg.c_str());
3838

3939
return M;
4040
}

llvm/unittests/Analysis/TargetLibraryInfoTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TargetLibraryInfoTest : public testing::Test {
3737
Error.print("", os);
3838

3939
if (!M)
40-
report_fatal_error(Twine(os.str()));
40+
report_fatal_error(Twine(errMsg));
4141
}
4242

4343
::testing::AssertionResult isLibFunc(const Function *FDecl,

llvm/unittests/Analysis/ValueTrackingTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ValueTrackingTest : public testing::Test {
5252
std::string errMsg;
5353
raw_string_ostream os(errMsg);
5454
Error.print("", os);
55-
EXPECT_TRUE(M) << os.str();
55+
EXPECT_TRUE(M) << errMsg;
5656

5757
return M;
5858
}
@@ -3003,7 +3003,7 @@ TEST_P(IsBytewiseValueTest, IsBytewiseValue) {
30033003
raw_string_ostream S(Buff);
30043004
if (Actual)
30053005
S << *Actual;
3006-
EXPECT_EQ(GetParam().first, S.str());
3006+
EXPECT_EQ(GetParam().first, Buff);
30073007
}
30083008

30093009
TEST_F(ValueTrackingTest, ComputeConstantRange) {

llvm/unittests/Analysis/VectorUtilsTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class VectorUtilsTest : public testing::Test {
3535

3636
// A failure here means that the test itself is buggy.
3737
if (!M)
38-
report_fatal_error(Twine(os.str()));
38+
report_fatal_error(Twine(errMsg));
3939

4040
Function *F = M->getFunction("test");
4141
if (F == nullptr)

llvm/unittests/InterfaceStub/ELFYAMLTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ TEST(ElfYamlTextAPI, YAMLWritesTBESymbols) {
237237
std::string Result;
238238
raw_string_ostream OS(Result);
239239
ASSERT_THAT_ERROR(writeIFSToOutputStream(OS, Moved), Succeeded());
240-
Result = OS.str();
241240
compareByLine(Result.c_str(), Expected);
242241
}
243242

@@ -267,6 +266,5 @@ TEST(ElfYamlTextAPI, YAMLWritesNoTBESyms) {
267266
std::string Result;
268267
raw_string_ostream OS(Result);
269268
ASSERT_THAT_ERROR(writeIFSToOutputStream(OS, Stub), Succeeded());
270-
Result = OS.str();
271269
compareByLine(Result.c_str(), Expected);
272270
}

llvm/unittests/Transforms/Coroutines/ExtraRematTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct ExtraRematTest : public testing::Test {
6363

6464
// A failure here means that the test itself is buggy.
6565
if (!M)
66-
report_fatal_error(os.str().c_str());
66+
report_fatal_error(errMsg.c_str());
6767
}
6868
};
6969

llvm/unittests/Transforms/Instrumentation/PGOInstrumentationTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ struct PGOInstrumentationGenTest
137137

138138
// A failure here means that the test itself is buggy.
139139
if (!M)
140-
report_fatal_error(OS.str().c_str());
140+
report_fatal_error(ErrMsg.c_str());
141141
}
142142
};
143143

llvm/unittests/Transforms/Utils/MemTransferLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct MemTransferLowerTest : public testing::Test {
8888

8989
// A failure here means that the test itself is buggy.
9090
if (!M)
91-
report_fatal_error(os.str().c_str());
91+
report_fatal_error(errMsg.c_str());
9292
}
9393
};
9494

0 commit comments

Comments
 (0)