[Lldb-commits] [lldb] [lldb] Improving unit test helpers by utilizing llvm helpers. (PR #119148)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Sun Dec 8 12:54:17 PST 2024


https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/119148

This was suggested in a previous patch after the commit was already submitted.

>From 4ad591f11b2dec8cf380ecbc02d18a6e6a0101a6 Mon Sep 17 00:00:00 2001
From: John Harrison <harjohn at google.com>
Date: Sun, 8 Dec 2024 12:15:14 -0800
Subject: [PATCH] [lldb] Improving unit test helpers by utilitizing llvm
 helpers.

This was suggested in a previous patch after the commit was already submitted.
---
 .../TestingSupport/Host/SocketTestUtilities.cpp    | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
index 80545b8c533a03..72ecde845567f7 100644
--- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
+++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp
@@ -122,10 +122,9 @@ bool lldb_private::HostSupportsLocalhostToIPv4() {
 
   auto addresses = SocketAddress::GetAddressInfo(
       "localhost", nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
-  return std::find_if(addresses.begin(), addresses.end(),
-                      [](SocketAddress &addr) {
-                        return addr.GetFamily() == AF_INET;
-                      }) != addresses.end();
+  return llvm::any_of(addresses, [](const SocketAddress &addr) {
+    return addr.GetFamily() == AF_INET;
+  });
 }
 
 bool lldb_private::HostSupportsLocalhostToIPv6() {
@@ -134,10 +133,9 @@ bool lldb_private::HostSupportsLocalhostToIPv6() {
 
   auto addresses = SocketAddress::GetAddressInfo(
       "localhost", nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
-  return std::find_if(addresses.begin(), addresses.end(),
-                      [](SocketAddress &addr) {
-                        return addr.GetFamily() == AF_INET6;
-                      }) != addresses.end();
+  return llvm::any_of(addresses, [](const SocketAddress &addr) {
+    return addr.GetFamily() == AF_INET6;
+  });
 }
 
 llvm::Expected<std::string> lldb_private::GetLocalhostIP() {



More information about the lldb-commits mailing list