From 6fd1c1b8ef407cb16f7c990a33908d289313559f Mon Sep 17 00:00:00 2001 From: Schrodinger ZHU Yifan Date: Mon, 4 Dec 2023 17:06:57 -0500 Subject: [PATCH] [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. --- libc/src/__support/HashTable/bitmask.h | 2 +- libc/src/__support/HashTable/generic/bitmask_impl.inc | 2 +- libc/test/src/__support/HashTable/CMakeLists.txt | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libc/src/__support/HashTable/bitmask.h b/libc/src/__support/HashTable/bitmask.h index 8247161c449b..38c986002059 100644 --- a/libc/src/__support/HashTable/bitmask.h +++ b/libc/src/__support/HashTable/bitmask.h @@ -73,7 +73,7 @@ template 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 b8d2bfc7a6ff..fd451a73488e 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 ee8dde107c3f..f84835fe95c7 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 ) -- 2.11.4.GIT