llvm.org GIT mirror llvm / 77a1dcd
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329475 91177308-0d34-0410-b5e6-96231b3b80d8 Mandeep Singh Grang 2 years ago
7 changed file(s) with 28 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
301301 ASSERT_EQ(V.begin() + 4, I);
302302
303303 // Sort the two halves as partition may have messed with the order.
304 std::sort(V.begin(), I);
305 std::sort(I, V.end());
304 llvm::sort(V.begin(), I);
305 llvm::sort(I, V.end());
306306
307307 EXPECT_EQ(2, V[0]);
308308 EXPECT_EQ(4, V[1]);
298298
299299 // Sort. We should hit the first element just once and the final element N
300300 // times.
301 std::sort(std::begin(Found), std::end(Found));
301 llvm::sort(std::begin(Found), std::end(Found));
302302 for (auto F = std::begin(Found), E = std::end(Found); F != E; ++F)
303303 EXPECT_EQ(F - Found + 1, *F);
304304 }
278278 Map["D"] = 3;
279279
280280 auto Keys = to_vector<4>(Map.keys());
281 std::sort(Keys.begin(), Keys.end());
281 llvm::sort(Keys.begin(), Keys.end());
282282
283283 SmallVector Expected = {"A", "B", "C", "D"};
284284 EXPECT_EQ(Expected, Keys);
292292 Set.insert("D");
293293
294294 auto Keys = to_vector<4>(Set.keys());
295 std::sort(Keys.begin(), Keys.end());
295 llvm::sort(Keys.begin(), Keys.end());
296296
297297 SmallVector Expected = {"A", "B", "C", "D"};
298298 EXPECT_EQ(Expected, Keys);
263263
264264 for (LazyCallGraph::Edge &E : A1.populate())
265265 Nodes.push_back(E.getFunction().getName());
266 std::sort(Nodes.begin(), Nodes.end());
266 llvm::sort(Nodes.begin(), Nodes.end());
267267 EXPECT_EQ("a2", Nodes[0]);
268268 EXPECT_EQ("b2", Nodes[1]);
269269 EXPECT_EQ("c3", Nodes[2]);
278278
279279 for (LazyCallGraph::Edge &E : B1.populate())
280280 Nodes.push_back(E.getFunction().getName());
281 std::sort(Nodes.begin(), Nodes.end());
281 llvm::sort(Nodes.begin(), Nodes.end());
282282 EXPECT_EQ("b2", Nodes[0]);
283283 EXPECT_EQ("d3", Nodes[1]);
284284 Nodes.clear();
292292
293293 for (LazyCallGraph::Edge &E : C1.populate())
294294 Nodes.push_back(E.getFunction().getName());
295 std::sort(Nodes.begin(), Nodes.end());
295 llvm::sort(Nodes.begin(), Nodes.end());
296296 EXPECT_EQ("c2", Nodes[0]);
297297 EXPECT_EQ("d2", Nodes[1]);
298298 Nodes.clear();
322322 ASSERT_EQ(1, D.size());
323323 for (LazyCallGraph::Node &N : *D.begin())
324324 Nodes.push_back(N.getFunction().getName());
325 std::sort(Nodes.begin(), Nodes.end());
325 llvm::sort(Nodes.begin(), Nodes.end());
326326 EXPECT_EQ(3u, Nodes.size());
327327 EXPECT_EQ("d1", Nodes[0]);
328328 EXPECT_EQ("d2", Nodes[1]);
338338 ASSERT_EQ(1, C.size());
339339 for (LazyCallGraph::Node &N : *C.begin())
340340 Nodes.push_back(N.getFunction().getName());
341 std::sort(Nodes.begin(), Nodes.end());
341 llvm::sort(Nodes.begin(), Nodes.end());
342342 EXPECT_EQ(3u, Nodes.size());
343343 EXPECT_EQ("c1", Nodes[0]);
344344 EXPECT_EQ("c2", Nodes[1]);
354354 ASSERT_EQ(1, B.size());
355355 for (LazyCallGraph::Node &N : *B.begin())
356356 Nodes.push_back(N.getFunction().getName());
357 std::sort(Nodes.begin(), Nodes.end());
357 llvm::sort(Nodes.begin(), Nodes.end());
358358 EXPECT_EQ(3u, Nodes.size());
359359 EXPECT_EQ("b1", Nodes[0]);
360360 EXPECT_EQ("b2", Nodes[1]);
372372 ASSERT_EQ(1, A.size());
373373 for (LazyCallGraph::Node &N : *A.begin())
374374 Nodes.push_back(N.getFunction().getName());
375 std::sort(Nodes.begin(), Nodes.end());
375 llvm::sort(Nodes.begin(), Nodes.end());
376376 EXPECT_EQ(3u, Nodes.size());
377377 EXPECT_EQ("a1", Nodes[0]);
378378 EXPECT_EQ("a2", Nodes[1]);
476476 LazyCallGraph::SCC &D = *J++;
477477 for (LazyCallGraph::Node &N : D)
478478 Nodes.push_back(N.getFunction().getName());
479 std::sort(Nodes.begin(), Nodes.end());
479 llvm::sort(Nodes.begin(), Nodes.end());
480480 EXPECT_EQ(3u, Nodes.size());
481481 EXPECT_EQ("d1", Nodes[0]);
482482 EXPECT_EQ("d2", Nodes[1]);
486486 LazyCallGraph::SCC &B = *J++;
487487 for (LazyCallGraph::Node &N : B)
488488 Nodes.push_back(N.getFunction().getName());
489 std::sort(Nodes.begin(), Nodes.end());
489 llvm::sort(Nodes.begin(), Nodes.end());
490490 EXPECT_EQ(3u, Nodes.size());
491491 EXPECT_EQ("b1", Nodes[0]);
492492 EXPECT_EQ("b2", Nodes[1]);
496496 LazyCallGraph::SCC &C = *J++;
497497 for (LazyCallGraph::Node &N : C)
498498 Nodes.push_back(N.getFunction().getName());
499 std::sort(Nodes.begin(), Nodes.end());
499 llvm::sort(Nodes.begin(), Nodes.end());
500500 EXPECT_EQ(3u, Nodes.size());
501501 EXPECT_EQ("c1", Nodes[0]);
502502 EXPECT_EQ("c2", Nodes[1]);
506506 LazyCallGraph::SCC &A = *J++;
507507 for (LazyCallGraph::Node &N : A)
508508 Nodes.push_back(N.getFunction().getName());
509 std::sort(Nodes.begin(), Nodes.end());
509 llvm::sort(Nodes.begin(), Nodes.end());
510510 EXPECT_EQ(3u, Nodes.size());
511511 EXPECT_EQ("a1", Nodes[0]);
512512 EXPECT_EQ("a2", Nodes[1]);
711711 };
712712 std::unique_ptr VD_0(
713713 Record.getValueForSite(IPVK_IndirectCallTarget, 0));
714 std::sort(&VD_0[0], &VD_0[5], Cmp);
714 llvm::sort(&VD_0[0], &VD_0[5], Cmp);
715715 ASSERT_EQ(StringRef((const char *)VD_0[0].Value, 7), StringRef("callee2"));
716716 ASSERT_EQ(1000U, VD_0[0].Count);
717717 ASSERT_EQ(StringRef((const char *)VD_0[1].Value, 7), StringRef("callee3"));
725725
726726 std::unique_ptr VD_1(
727727 Record.getValueForSite(IPVK_IndirectCallTarget, 1));
728 std::sort(&VD_1[0], &VD_1[4], Cmp);
728 llvm::sort(&VD_1[0], &VD_1[4], Cmp);
729729 ASSERT_EQ(StringRef((const char *)VD_1[0].Value, 7), StringRef("callee2"));
730730 ASSERT_EQ(2500U, VD_1[0].Count);
731731 ASSERT_EQ(StringRef((const char *)VD_1[1].Value, 7), StringRef("callee1"));
737737
738738 std::unique_ptr VD_2(
739739 Record.getValueForSite(IPVK_IndirectCallTarget, 2));
740 std::sort(&VD_2[0], &VD_2[3], Cmp);
740 llvm::sort(&VD_2[0], &VD_2[3], Cmp);
741741 ASSERT_EQ(StringRef((const char *)VD_2[0].Value, 7), StringRef("callee4"));
742742 ASSERT_EQ(5500U, VD_2[0].Count);
743743 ASSERT_EQ(StringRef((const char *)VD_2[1].Value, 7), StringRef("callee3"));
747747
748748 std::unique_ptr VD_3(
749749 Record.getValueForSite(IPVK_IndirectCallTarget, 3));
750 std::sort(&VD_3[0], &VD_3[2], Cmp);
750 llvm::sort(&VD_3[0], &VD_3[2], Cmp);
751751 ASSERT_EQ(StringRef((const char *)VD_3[0].Value, 7), StringRef("callee3"));
752752 ASSERT_EQ(2000U, VD_3[0].Count);
753753 ASSERT_EQ(StringRef((const char *)VD_3[1].Value, 7), StringRef("callee2"));
780780 };
781781 std::unique_ptr VD_0(
782782 Record.getValueForSite(IPVK_IndirectCallTarget, 0));
783 std::sort(&VD_0[0], &VD_0[5], Cmp);
783 llvm::sort(&VD_0[0], &VD_0[5], Cmp);
784784 ASSERT_EQ(VD_0[0].Value, 0x2000ULL);
785785 ASSERT_EQ(1000U, VD_0[0].Count);
786786 ASSERT_EQ(VD_0[1].Value, 0x3000ULL);
899899 ASSERT_NO_ERROR(ec);
900900 VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
901901 }
902 std::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
903 std::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
902 llvm::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
903 llvm::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
904904 v_t ExpectedNonBrokenSymlinks = {"b", "d"};
905905 ASSERT_EQ(ExpectedNonBrokenSymlinks.size(), VisitedNonBrokenSymlinks.size());
906906 ASSERT_TRUE(std::equal(VisitedNonBrokenSymlinks.begin(),
926926 ASSERT_NO_ERROR(ec);
927927 VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
928928 }
929 std::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
930 std::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
929 llvm::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
930 llvm::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
931931 ExpectedNonBrokenSymlinks = {"b", "bb", "d", "da", "dd", "ddd", "ddd"};
932932 ASSERT_EQ(ExpectedNonBrokenSymlinks.size(), VisitedNonBrokenSymlinks.size());
933933 ASSERT_TRUE(std::equal(VisitedNonBrokenSymlinks.begin(),
953953 ASSERT_NO_ERROR(ec);
954954 VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
955955 }
956 std::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
957 std::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
956 llvm::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
957 llvm::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
958958 ExpectedNonBrokenSymlinks = {"a", "b", "ba", "bb", "bc", "c", "d", "da", "dd",
959959 "ddd", "e"};
960960 ASSERT_EQ(ExpectedNonBrokenSymlinks.size(), VisitedNonBrokenSymlinks.size());
26532653 LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
26542654 ::std::vector sorted_container(lhs_stl_container.begin(),
26552655 lhs_stl_container.end());
2656 ::std::sort(
2656 ::llvm::sort(
26572657 sorted_container.begin(), sorted_container.end(), comparator_);
26582658
26592659 if (!listener->IsInterested()) {