1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[unittests] Change std::sort to llvm::sort in response to r327219

r327219 added wrappers to std::sort which randomly shuffle the container before
sorting.  This will help in uncovering non-determinism caused due to undefined
sorting order of objects having the same key.

To make use of that infrastructure we need to invoke llvm::sort instead of
std::sort.

Note: This patch is one of a series of patches to replace *all* std::sort to
llvm::sort.  Refer the comments section in D44363 for a list of all the
required patches.

llvm-svn: 329475
This commit is contained in:
Mandeep Singh Grang 2018-04-07 01:29:45 +00:00
parent cded1d3751
commit 0068f19cfd
7 changed files with 28 additions and 28 deletions

View File

@ -302,8 +302,8 @@ TEST(STLExtrasTest, PartitionAdaptor) {
ASSERT_EQ(V.begin() + 4, I);
// Sort the two halves as partition may have messed with the order.
std::sort(V.begin(), I);
std::sort(I, V.end());
llvm::sort(V.begin(), I);
llvm::sort(I, V.end());
EXPECT_EQ(2, V[0]);
EXPECT_EQ(4, V[1]);

View File

@ -299,7 +299,7 @@ TEST(SmallPtrSetTest, dereferenceAndIterate) {
// Sort. We should hit the first element just once and the final element N
// times.
std::sort(std::begin(Found), std::end(Found));
llvm::sort(std::begin(Found), std::end(Found));
for (auto F = std::begin(Found), E = std::end(Found); F != E; ++F)
EXPECT_EQ(F - Found + 1, *F);
}

View File

@ -279,7 +279,7 @@ TEST_F(StringMapTest, IterMapKeys) {
Map["D"] = 3;
auto Keys = to_vector<4>(Map.keys());
std::sort(Keys.begin(), Keys.end());
llvm::sort(Keys.begin(), Keys.end());
SmallVector<StringRef, 4> Expected = {"A", "B", "C", "D"};
EXPECT_EQ(Expected, Keys);
@ -293,7 +293,7 @@ TEST_F(StringMapTest, IterSetKeys) {
Set.insert("D");
auto Keys = to_vector<4>(Set.keys());
std::sort(Keys.begin(), Keys.end());
llvm::sort(Keys.begin(), Keys.end());
SmallVector<StringRef, 4> Expected = {"A", "B", "C", "D"};
EXPECT_EQ(Expected, Keys);

View File

@ -264,7 +264,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
for (LazyCallGraph::Edge &E : A1.populate())
Nodes.push_back(E.getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
llvm::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ("a2", Nodes[0]);
EXPECT_EQ("b2", Nodes[1]);
EXPECT_EQ("c3", Nodes[2]);
@ -279,7 +279,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
for (LazyCallGraph::Edge &E : B1.populate())
Nodes.push_back(E.getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
llvm::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ("b2", Nodes[0]);
EXPECT_EQ("d3", Nodes[1]);
Nodes.clear();
@ -293,7 +293,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
for (LazyCallGraph::Edge &E : C1.populate())
Nodes.push_back(E.getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
llvm::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ("c2", Nodes[0]);
EXPECT_EQ("d2", Nodes[1]);
Nodes.clear();
@ -323,7 +323,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
ASSERT_EQ(1, D.size());
for (LazyCallGraph::Node &N : *D.begin())
Nodes.push_back(N.getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
llvm::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("d1", Nodes[0]);
EXPECT_EQ("d2", Nodes[1]);
@ -339,7 +339,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
ASSERT_EQ(1, C.size());
for (LazyCallGraph::Node &N : *C.begin())
Nodes.push_back(N.getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
llvm::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("c1", Nodes[0]);
EXPECT_EQ("c2", Nodes[1]);
@ -355,7 +355,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
ASSERT_EQ(1, B.size());
for (LazyCallGraph::Node &N : *B.begin())
Nodes.push_back(N.getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
llvm::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("b1", Nodes[0]);
EXPECT_EQ("b2", Nodes[1]);
@ -373,7 +373,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
ASSERT_EQ(1, A.size());
for (LazyCallGraph::Node &N : *A.begin())
Nodes.push_back(N.getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
llvm::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("a1", Nodes[0]);
EXPECT_EQ("a2", Nodes[1]);
@ -477,7 +477,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) {
LazyCallGraph::SCC &D = *J++;
for (LazyCallGraph::Node &N : D)
Nodes.push_back(N.getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
llvm::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("d1", Nodes[0]);
EXPECT_EQ("d2", Nodes[1]);
@ -487,7 +487,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) {
LazyCallGraph::SCC &B = *J++;
for (LazyCallGraph::Node &N : B)
Nodes.push_back(N.getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
llvm::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("b1", Nodes[0]);
EXPECT_EQ("b2", Nodes[1]);
@ -497,7 +497,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) {
LazyCallGraph::SCC &C = *J++;
for (LazyCallGraph::Node &N : C)
Nodes.push_back(N.getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
llvm::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("c1", Nodes[0]);
EXPECT_EQ("c2", Nodes[1]);
@ -507,7 +507,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) {
LazyCallGraph::SCC &A = *J++;
for (LazyCallGraph::Node &N : A)
Nodes.push_back(N.getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
llvm::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ(3u, Nodes.size());
EXPECT_EQ("a1", Nodes[0]);
EXPECT_EQ("a2", Nodes[1]);

View File

@ -712,7 +712,7 @@ TEST_P(MaybeSparseInstrProfTest, value_prof_data_read_write) {
};
std::unique_ptr<InstrProfValueData[]> VD_0(
Record.getValueForSite(IPVK_IndirectCallTarget, 0));
std::sort(&VD_0[0], &VD_0[5], Cmp);
llvm::sort(&VD_0[0], &VD_0[5], Cmp);
ASSERT_EQ(StringRef((const char *)VD_0[0].Value, 7), StringRef("callee2"));
ASSERT_EQ(1000U, VD_0[0].Count);
ASSERT_EQ(StringRef((const char *)VD_0[1].Value, 7), StringRef("callee3"));
@ -726,7 +726,7 @@ TEST_P(MaybeSparseInstrProfTest, value_prof_data_read_write) {
std::unique_ptr<InstrProfValueData[]> VD_1(
Record.getValueForSite(IPVK_IndirectCallTarget, 1));
std::sort(&VD_1[0], &VD_1[4], Cmp);
llvm::sort(&VD_1[0], &VD_1[4], Cmp);
ASSERT_EQ(StringRef((const char *)VD_1[0].Value, 7), StringRef("callee2"));
ASSERT_EQ(2500U, VD_1[0].Count);
ASSERT_EQ(StringRef((const char *)VD_1[1].Value, 7), StringRef("callee1"));
@ -738,7 +738,7 @@ TEST_P(MaybeSparseInstrProfTest, value_prof_data_read_write) {
std::unique_ptr<InstrProfValueData[]> VD_2(
Record.getValueForSite(IPVK_IndirectCallTarget, 2));
std::sort(&VD_2[0], &VD_2[3], Cmp);
llvm::sort(&VD_2[0], &VD_2[3], Cmp);
ASSERT_EQ(StringRef((const char *)VD_2[0].Value, 7), StringRef("callee4"));
ASSERT_EQ(5500U, VD_2[0].Count);
ASSERT_EQ(StringRef((const char *)VD_2[1].Value, 7), StringRef("callee3"));
@ -748,7 +748,7 @@ TEST_P(MaybeSparseInstrProfTest, value_prof_data_read_write) {
std::unique_ptr<InstrProfValueData[]> VD_3(
Record.getValueForSite(IPVK_IndirectCallTarget, 3));
std::sort(&VD_3[0], &VD_3[2], Cmp);
llvm::sort(&VD_3[0], &VD_3[2], Cmp);
ASSERT_EQ(StringRef((const char *)VD_3[0].Value, 7), StringRef("callee3"));
ASSERT_EQ(2000U, VD_3[0].Count);
ASSERT_EQ(StringRef((const char *)VD_3[1].Value, 7), StringRef("callee2"));
@ -781,7 +781,7 @@ TEST_P(MaybeSparseInstrProfTest, value_prof_data_read_write_mapping) {
};
std::unique_ptr<InstrProfValueData[]> VD_0(
Record.getValueForSite(IPVK_IndirectCallTarget, 0));
std::sort(&VD_0[0], &VD_0[5], Cmp);
llvm::sort(&VD_0[0], &VD_0[5], Cmp);
ASSERT_EQ(VD_0[0].Value, 0x2000ULL);
ASSERT_EQ(1000U, VD_0[0].Count);
ASSERT_EQ(VD_0[1].Value, 0x3000ULL);

View File

@ -900,8 +900,8 @@ TEST_F(FileSystemTest, BrokenSymlinkDirectoryIteration) {
ASSERT_NO_ERROR(ec);
VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
}
std::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
std::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
llvm::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
llvm::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
v_t ExpectedNonBrokenSymlinks = {"b", "d"};
ASSERT_EQ(ExpectedNonBrokenSymlinks.size(), VisitedNonBrokenSymlinks.size());
ASSERT_TRUE(std::equal(VisitedNonBrokenSymlinks.begin(),
@ -927,8 +927,8 @@ TEST_F(FileSystemTest, BrokenSymlinkDirectoryIteration) {
ASSERT_NO_ERROR(ec);
VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
}
std::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
std::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
llvm::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
llvm::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
ExpectedNonBrokenSymlinks = {"b", "bb", "d", "da", "dd", "ddd", "ddd"};
ASSERT_EQ(ExpectedNonBrokenSymlinks.size(), VisitedNonBrokenSymlinks.size());
ASSERT_TRUE(std::equal(VisitedNonBrokenSymlinks.begin(),
@ -954,8 +954,8 @@ TEST_F(FileSystemTest, BrokenSymlinkDirectoryIteration) {
ASSERT_NO_ERROR(ec);
VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
}
std::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
std::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
llvm::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
llvm::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
ExpectedNonBrokenSymlinks = {"a", "b", "ba", "bb", "bc", "c", "d", "da", "dd",
"ddd", "e"};
ASSERT_EQ(ExpectedNonBrokenSymlinks.size(), VisitedNonBrokenSymlinks.size());

View File

@ -2654,7 +2654,7 @@ class WhenSortedByMatcher {
LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
::std::vector<LhsValue> sorted_container(lhs_stl_container.begin(),
lhs_stl_container.end());
::std::sort(
::llvm::sort(
sorted_container.begin(), sorted_container.end(), comparator_);
if (!listener->IsInterested()) {