[libc-commits] [libc] [libc] fix HashTable warnings and build problems (PR #74371)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Mon Dec 4 13:30:29 PST 2023


https://github.com/SchrodingerZhu updated https://github.com/llvm/llvm-project/pull/74371

>From 7eb89f406bc94baebd53232b1183ad23518ed7e5 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: Mon, 4 Dec 2023 16:17:31 -0500
Subject: [PATCH 1/2] [libc] fix HashTable warnings and build problems

---
 libc/src/__support/HashTable/bitmask.h                |  2 +-
 libc/src/__support/HashTable/generic/bitmask_impl.inc |  2 +-
 libc/test/src/__support/CMakeLists.txt                | 10 +++++++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libc/src/__support/HashTable/bitmask.h b/libc/src/__support/HashTable/bitmask.h
index 8247161c449bd..821735e22f0a4 100644
--- a/libc/src/__support/HashTable/bitmask.h
+++ b/libc/src/__support/HashTable/bitmask.h
@@ -73,7 +73,7 @@ template <class BitMask> struct IteratableBitMaskAdaptor : public BitMask {
     return *this;
   }
   LIBC_INLINE IteratableBitMaskAdaptor begin() { return *this; }
-  LIBC_INLINE IteratableBitMaskAdaptor end() { return {0}; }
+  LIBC_INLINE IteratableBitMaskAdaptor end() { return {{0}}; }
   LIBC_INLINE bool operator==(const IteratableBitMaskAdaptor &other) {
     return this->word == other.word;
   }
diff --git a/libc/src/__support/HashTable/generic/bitmask_impl.inc b/libc/src/__support/HashTable/generic/bitmask_impl.inc
index b8d2bfc7a6ff2..623b51f238df5 100644
--- a/libc/src/__support/HashTable/generic/bitmask_impl.inc
+++ b/libc/src/__support/HashTable/generic/bitmask_impl.inc
@@ -98,7 +98,7 @@ struct Group {
     auto cmp = data ^ repeat_byte(byte);
     auto result = LIBC_NAMESPACE::Endian::to_little_endian(
         (cmp - repeat_byte(0x01)) & ~cmp & repeat_byte(0x80));
-    return {result};
+    return {{result}};
   }
 
   // Find out the lanes equal to EMPTY or DELETE (highest bit set) and
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 2b9fa93bb548e..6db0e53055b25 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -181,4 +181,12 @@ add_subdirectory(File)
 add_subdirectory(RPC)
 add_subdirectory(OSUtil)
 add_subdirectory(FPUtil)
-add_subdirectory(HashTable)
+
+list(FIND TARGET_ENTRYPOINT_NAME_LIST hsearch hsearch_index)
+list(FIND TARGET_ENTRYPOINT_NAME_LIST hsearch_r hsearch_r_index)
+
+if (${hsearch_index} EQUAL -1 AND ${hsearch_r_index} EQUAL -1)
+  message(STATUS "Skipping HashTable tests since hsearch and hsearch_r are not built.")
+else()
+  add_subdirectory(HashTable)
+endif()

>From fb33d5e9ac204a31c66a7f085faa91fa09bf26b4 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: Mon, 4 Dec 2023 16:30:13 -0500
Subject: [PATCH 2/2] address CRs

---
 libc/src/__support/HashTable/bitmask.h                |  2 +-
 libc/src/__support/HashTable/generic/bitmask_impl.inc |  2 +-
 libc/test/src/__support/CMakeLists.txt                | 10 +---------
 libc/test/src/__support/HashTable/CMakeLists.txt      |  3 +++
 4 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/libc/src/__support/HashTable/bitmask.h b/libc/src/__support/HashTable/bitmask.h
index 821735e22f0a4..38c9860020594 100644
--- a/libc/src/__support/HashTable/bitmask.h
+++ b/libc/src/__support/HashTable/bitmask.h
@@ -73,7 +73,7 @@ template <class BitMask> struct IteratableBitMaskAdaptor : public BitMask {
     return *this;
   }
   LIBC_INLINE IteratableBitMaskAdaptor begin() { return *this; }
-  LIBC_INLINE IteratableBitMaskAdaptor end() { return {{0}}; }
+  LIBC_INLINE IteratableBitMaskAdaptor end() { return {BitMask{0}}; }
   LIBC_INLINE bool operator==(const IteratableBitMaskAdaptor &other) {
     return this->word == other.word;
   }
diff --git a/libc/src/__support/HashTable/generic/bitmask_impl.inc b/libc/src/__support/HashTable/generic/bitmask_impl.inc
index 623b51f238df5..fd451a73488e7 100644
--- a/libc/src/__support/HashTable/generic/bitmask_impl.inc
+++ b/libc/src/__support/HashTable/generic/bitmask_impl.inc
@@ -98,7 +98,7 @@ struct Group {
     auto cmp = data ^ repeat_byte(byte);
     auto result = LIBC_NAMESPACE::Endian::to_little_endian(
         (cmp - repeat_byte(0x01)) & ~cmp & repeat_byte(0x80));
-    return {{result}};
+    return {BitMask{result}};
   }
 
   // Find out the lanes equal to EMPTY or DELETE (highest bit set) and
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 6db0e53055b25..2b9fa93bb548e 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -181,12 +181,4 @@ add_subdirectory(File)
 add_subdirectory(RPC)
 add_subdirectory(OSUtil)
 add_subdirectory(FPUtil)
-
-list(FIND TARGET_ENTRYPOINT_NAME_LIST hsearch hsearch_index)
-list(FIND TARGET_ENTRYPOINT_NAME_LIST hsearch_r hsearch_r_index)
-
-if (${hsearch_index} EQUAL -1 AND ${hsearch_r_index} EQUAL -1)
-  message(STATUS "Skipping HashTable tests since hsearch and hsearch_r are not built.")
-else()
-  add_subdirectory(HashTable)
-endif()
+add_subdirectory(HashTable)
diff --git a/libc/test/src/__support/HashTable/CMakeLists.txt b/libc/test/src/__support/HashTable/CMakeLists.txt
index ee8dde107c3fe..f84835fe95c7c 100644
--- a/libc/test/src/__support/HashTable/CMakeLists.txt
+++ b/libc/test/src/__support/HashTable/CMakeLists.txt
@@ -6,6 +6,7 @@ add_libc_test(
     bitmask_test.cpp
   DEPENDS
     libc.src.__support.HashTable.bitmask
+    libc.src.search.hsearch
 )
 
 add_libc_test(
@@ -18,6 +19,7 @@ add_libc_test(
     libc.src.__support.HashTable.randomness
     libc.src.__support.HashTable.table
     libc.src.__support.common
+    libc.src.search.hsearch
   UNIT_TEST_ONLY
 )
 
@@ -30,4 +32,5 @@ add_libc_test(
   DEPENDS
     libc.src.__support.HashTable.bitmask
     libc.src.stdlib.rand
+    libc.src.search.hsearch
 )



More information about the libc-commits mailing list