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

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented May 24, 2025

@llvm/pr-subscribers-xray

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/141318.diff

1 Files Affected:

  • (modified) llvm/unittests/XRay/GraphTest.cpp (+10-30)
diff --git a/llvm/unittests/XRay/GraphTest.cpp b/llvm/unittests/XRay/GraphTest.cpp
index faf10ea96ce2e..37f07cc721c61 100644
--- a/llvm/unittests/XRay/GraphTest.cpp
+++ b/llvm/unittests/XRay/GraphTest.cpp
@@ -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());
   }
 
@@ -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());
   }
 
@@ -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));
   }
 }
 

@kazutakahirata kazutakahirata merged commit d71dcfa into llvm:main May 24, 2025
11 of 13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250523_llvm_is_contained_llvm_XRay branch May 24, 2025 07:00
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants