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

via libc-commits libc-commits at lists.llvm.org
Mon Dec 4 14:07:02 PST 2023


Author: Schrodinger ZHU Yifan
Date: 2023-12-04T14:06:57-08:00
New Revision: 6fd1c1b8ef407cb16f7c990a33908d289313559f

URL: https://github.com/llvm/llvm-project/commit/6fd1c1b8ef407cb16f7c990a33908d289313559f
DIFF: https://github.com/llvm/llvm-project/commit/6fd1c1b8ef407cb16f7c990a33908d289313559f.diff

LOG: [libc] fix HashTable warnings and build problems (#74371)

According to https://lab.llvm.org/buildbot/#/builders/163/builds/48002,
the generic build on HashTable fails with two major issues with
`werror`:
1. warnings on `error: suggest braces around initialization of
subobject`.
2. `__support/HashTable` tests are built regardless of its entrypoints`

This PR attempts to fix such issues.

Added: 
    

Modified: 
    libc/src/__support/HashTable/bitmask.h
    libc/src/__support/HashTable/generic/bitmask_impl.inc
    libc/test/src/__support/HashTable/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/HashTable/bitmask.h b/libc/src/__support/HashTable/bitmask.h
index 8247161c449bd..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 b8d2bfc7a6ff2..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/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