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

via libc-commits libc-commits at lists.llvm.org
Mon Dec 4 13:18:26 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

<details>
<summary>Changes</summary>



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


3 Files Affected:

- (modified) libc/src/__support/HashTable/bitmask.h (+1-1) 
- (modified) libc/src/__support/HashTable/generic/bitmask_impl.inc (+1-1) 
- (modified) libc/test/src/__support/CMakeLists.txt (+9-1) 


``````````diff
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()

``````````

</details>


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


More information about the libc-commits mailing list