Skip to content

[XRay] Use llvm::is_contained (NFC) #141318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 10 additions & 30 deletions llvm/unittests/XRay/GraphTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ template <typename T> void graphVertexTester(T &G) {
ASSERT_TRUE(!!EVV);
EXPECT_EQ(1u, G.count(u));
EXPECT_EQ(VA[u], EVV->VA);
EXPECT_NE(G.vertices().end(),
llvm::find_if(G.vertices(),
[&](const VVT &VV) { return VV.first == u; }));
EXPECT_TRUE(llvm::is_contained(llvm::make_first_range(G.vertices()), u));
consumeError(EVV.takeError());
}

Expand All @@ -97,8 +95,7 @@ template <typename T> void graphEdgeTester(T &G) {
EXPECT_EQ(1u, G.count(u));
EXPECT_EQ(VA[u.first] * VA[u.second] * ((u.first > u.second) ? 2 : 1),
EEV->EA);
auto Pred = [&](const EVT &EV) { return EV.first == u; };
EXPECT_NE(G.edges().end(), llvm::find_if(G.edges(), Pred));
EXPECT_TRUE(llvm::is_contained(llvm::make_first_range(G.edges()), u));
consumeError(EEV.takeError());
}

Expand All @@ -113,31 +110,14 @@ template <typename T> void graphEdgeTester(T &G) {
EXPECT_NE(OE.size(), 0u);
EXPECT_NE(IE.begin(), IE.end());
EXPECT_NE(OE.begin(), OE.end());
{
auto It = std::find_if(
G.inEdges(EV.first.second).begin(), G.inEdges(EV.first.second).end(),
[&](const EVT &EVI) { return EVI.first == EV.first; });
EXPECT_NE(G.inEdges(EV.first.second).end(), It);
}
{
auto It = std::find_if(
G.inEdges(EV.first.first).begin(), G.inEdges(EV.first.first).end(),
[&](const EVT &EVI) { return EVI.first == EV.first; });
EXPECT_EQ(G.inEdges(EV.first.first).end(), It);
}
{
auto It =
std::find_if(G.outEdges(EV.first.second).begin(),
G.outEdges(EV.first.second).end(),
[&](const EVT &EVI) { return EVI.first == EV.first; });
EXPECT_EQ(G.outEdges(EV.first.second).end(), It);
}
{
auto It = std::find_if(
G.outEdges(EV.first.first).begin(), G.outEdges(EV.first.first).end(),
[&](const EVT &EVI) { return EVI.first == EV.first; });
EXPECT_NE(G.outEdges(EV.first.first).end(), It);
}
EXPECT_TRUE(llvm::is_contained(
llvm::make_first_range(G.inEdges(EV.first.second)), EV.first));
EXPECT_FALSE(llvm::is_contained(
llvm::make_first_range(G.inEdges(EV.first.first)), EV.first));
EXPECT_FALSE(llvm::is_contained(
llvm::make_first_range(G.outEdges(EV.first.second)), EV.first));
EXPECT_TRUE(llvm::is_contained(
llvm::make_first_range(G.outEdges(EV.first.first)), EV.first));
}
}

Expand Down
Loading