diff --git a/libcxx/include/__config b/libcxx/include/__config index af8a297fdf3fd..2b15e53dcb3b7 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(reason) __attribute__((__no_sanitize__("integer"))) # else # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK +# define _LIBCPP_DISABLE_UBSAN_INTEGER_CHECK(reason) # endif # if __has_feature(nullability) diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h index 489a6f00b8a3d..d5566bb7e3949 100644 --- a/libcxx/include/__functional/hash.h +++ b/libcxx/include/__functional/hash.h @@ -132,11 +132,13 @@ 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("shifting can cause unsigned overflow") + __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("shifting can cause unsigned overflow") + __rotate_by_at_least_1(_Size __val, int __shift) { return (__val >> __shift) | (__val << (64 - __shift)); }