summaryrefslogtreecommitdiffstats
path: root/libcxx/include
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2016-01-11 19:27:10 +0000
committerMarshall Clow <mclow.lists@gmail.com>2016-01-11 19:27:10 +0000
commitec880422df150c367e6025b152d7a8e2616d7b3d (patch)
treec498799a21153963f762a971f12c2e6c18fc82be /libcxx/include
parent2246359309f4ca25ef5f631dd3093e5b95377b8b (diff)
downloadbcm5719-llvm-ec880422df150c367e6025b152d7a8e2616d7b3d.tar.gz
bcm5719-llvm-ec880422df150c367e6025b152d7a8e2616d7b3d.zip
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
llvm-svn: 257368
Diffstat (limited to 'libcxx/include')
-rw-r--r--libcxx/include/__config9
-rw-r--r--libcxx/include/memory4
2 files changed, 11 insertions, 2 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config
index c0b1ef201c0..b6f7bd3b34c 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -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_contiguous_container(
#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
diff --git a/libcxx/include/memory b/libcxx/include/memory
index 65369d2632c..3ef687c1774 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -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) {
OpenPOWER on IntegriCloud