Author: marshall Date: Mon Jan 11 13:27:10 2016 New Revision: 257368 URL: http://llvm.org/viewvc/llvm-project?rev=257368&view=rev Log: Preemptively disable unsigned integer sanitization in 32 and 64 bit versions of __murmur2_or_cityhash. This lets people use the unsigned integer overflow checker in UBSAN w/o getting hits from libc++'s hash code (where the unsigned integer overflow is legal and deliberate)> Patch by @danielaustin. Reviewed as: http://reviews.llvm.org/D15973
Modified: libcxx/trunk/include/__config libcxx/trunk/include/memory Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=257368&r1=257367&r2=257368&view=diff ============================================================================== --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Mon Jan 11 13:27:10 2016 @@ -597,6 +597,11 @@ namespace std { #define _LIBCPP_HAS_NO_ASAN +// Allow for build-time disabling of unsigned integer sanitization +#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK +#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute((no_sanitize("unsigned integer"))) +#endif + #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__ #ifndef _LIBCPP_HAS_NO_NOEXCEPT @@ -826,6 +831,10 @@ extern "C" void __sanitizer_annotate_con #define _LIBCPP_HAS_NO_ATOMIC_HEADER #endif +#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK +#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK +#endif + #endif // __cplusplus #endif // _LIBCPP_CONFIG Modified: libcxx/trunk/include/memory URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=257368&r1=257367&r2=257368&view=diff ============================================================================== --- libcxx/trunk/include/memory (original) +++ libcxx/trunk/include/memory Mon Jan 11 13:27:10 2016 @@ -3194,7 +3194,7 @@ struct __murmur2_or_cityhash<_Size, 32> // murmur2 template <class _Size> _Size -__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) +__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { const _Size __m = 0x5bd1e995; const _Size __r = 24; @@ -3344,7 +3344,7 @@ struct __murmur2_or_cityhash<_Size, 64> // cityhash64 template <class _Size> _Size -__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) +__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { const char* __s = static_cast<const char*>(__key); if (__len <= 32) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits