[libcxx-commits] [PATCH] D144107: [libc++] Add regression test for std::hash implementation in ABI v1

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 15 07:50:45 PST 2023


ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144107

Files:
  libcxx/test/libcxx/utilities/utility/__murmur2_or_cityhash.abi-v1.pass.cpp
  libcxx/test/libcxx/utilities/utility/__murmur2_or_cityhash.abi-v2.pass.cpp
  libcxx/test/libcxx/utilities/utility/__murmur2_or_cityhash.pass.cpp


Index: libcxx/test/libcxx/utilities/utility/__murmur2_or_cityhash.abi-v2.pass.cpp
===================================================================
--- libcxx/test/libcxx/utilities/utility/__murmur2_or_cityhash.abi-v2.pass.cpp
+++ libcxx/test/libcxx/utilities/utility/__murmur2_or_cityhash.abi-v2.pass.cpp
@@ -6,10 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-// Test the CityHash implementation is correct.
-
 // UNSUPPORTED: c++03
 
+// Test that the CityHash implementation is correct.
+//
 // In ABI v1, our CityHash implementation is incorrect and fixing it would
 // be an ABI break.
 // REQUIRES: libcpp-abi-version=2
Index: libcxx/test/libcxx/utilities/utility/__murmur2_or_cityhash.abi-v1.pass.cpp
===================================================================
--- libcxx/test/libcxx/utilities/utility/__murmur2_or_cityhash.abi-v1.pass.cpp
+++ libcxx/test/libcxx/utilities/utility/__murmur2_or_cityhash.abi-v1.pass.cpp
@@ -6,13 +6,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-// Test the CityHash implementation is correct.
-
 // UNSUPPORTED: c++03
 
-// In ABI v1, our CityHash implementation is incorrect and fixing it would
-// be an ABI break.
-// REQUIRES: libcpp-abi-version=2
+// Test that the CityHash implementation returns the results we expect.
+//
+// Note that this implementation is technically incorrect, however changing it is
+// an ABI break. This test ensures that we don't unintentionally break the ABI v1
+// by "fixing" the hash implementation.
+// REQUIRES: libcpp-abi-version=1
 
 #include <cassert>
 #include <string>
@@ -33,10 +34,10 @@
 
 int main(int, char**) {
   const std::pair<std::string, uint64_t> TestCases[] = {
-      {CityHash[0], CHOOSE_BY_ENDIANESS(0x4382a8d0fe8edb17ULL, 0xca84e809bef16fbcULL)},
-      {CityHash[1], CHOOSE_BY_ENDIANESS(0xecefb080a6854061ULL, 0xd7feb824250272dcULL)},
-      {CityHash[2], CHOOSE_BY_ENDIANESS(0x169ea3aebf908d6dULL, 0xea8cef3ca6f6e368ULL)},
-      {CityHash[3], CHOOSE_BY_ENDIANESS(0xe18298a2760f09faULL, 0xf33a7700bb7a94a8ULL)},
+      {CityHash[0], CHOOSE_BY_ENDIANESS(0x87c69099911bab7eULL, 0x7eab1b919990c687ULL)},
+      {CityHash[1], CHOOSE_BY_ENDIANESS(0x87c69099911bab7eULL, 0x7eab1b919990c687ULL)},
+      {CityHash[2], CHOOSE_BY_ENDIANESS(0x85322632e188694aULL, 0x4a6988e132263285ULL)},
+      {CityHash[3], CHOOSE_BY_ENDIANESS(0x85322632e188694aULL, 0x4a6988e132263285ULL)},
   };
 
   std::__murmur2_or_cityhash<uint64_t> h64;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144107.497677.patch
Type: text/x-patch
Size: 2532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230215/0f706b22/attachment.bin>


More information about the libcxx-commits mailing list