[libcxx-commits] [libcxx] libcxx: fix bogus integer sanitizer warnings in hash helpers (PR #146715)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 2 08:01:21 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Jean-Michaƫl Celerier (jcelerier)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/146715.diff
2 Files Affected:
- (modified) libcxx/include/__config (+2)
- (modified) libcxx/include/__functional/hash.h (+3-2)
``````````diff
diff --git a/libcxx/include/__config b/libcxx/include/__config
index af8a297fdf3fd..5bbb54f94ae23 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1156,8 +1156,10 @@ typedef __char32_t char32_t;
// Allow for build-time disabling of unsigned integer sanitization
# if __has_attribute(no_sanitize) && !defined(_LIBCPP_COMPILER_GCC)
# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
+# define _LIBCPP_DISABLE_UBSAN_INTEGER_CHECK __attribute__((__no_sanitize__("integer")))
# else
# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+# define _LIBCPP_DISABLE_UBSAN_INTEGER_CHECK
# endif
# if __has_feature(nullability)
diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h
index 489a6f00b8a3d..5c4fa39c772f5 100644
--- a/libcxx/include/__functional/hash.h
+++ b/libcxx/include/__functional/hash.h
@@ -132,11 +132,12 @@ struct __murmur2_or_cityhash<_Size, 64> {
static const _Size __k2 = 0x9ae16a3b2f90404fULL;
static const _Size __k3 = 0xc949d7c7509e6557ULL;
- _LIBCPP_HIDE_FROM_ABI static _Size __rotate(_Size __val, int __shift) {
+ _LIBCPP_HIDE_FROM_ABI static _Size _LIBCPP_DISABLE_UBSAN_INTEGER_CHECK __rotate(_Size __val, int __shift) {
return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift)));
}
- _LIBCPP_HIDE_FROM_ABI static _Size __rotate_by_at_least_1(_Size __val, int __shift) {
+ _LIBCPP_HIDE_FROM_ABI static _Size _LIBCPP_DISABLE_UBSAN_INTEGER_CHECK
+ __rotate_by_at_least_1(_Size __val, int __shift) {
return (__val >> __shift) | (__val << (64 - __shift));
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/146715
More information about the libcxx-commits
mailing list