| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef _LIBCPP___LIBCXX_DEBUG_UTILS_SANITIZERS_H |
| #define _LIBCPP___LIBCXX_DEBUG_UTILS_SANITIZERS_H |
|
|
| #include <__config> |
| #include <__type_traits/integral_constant.h> |
| #include <__type_traits/is_constant_evaluated.h> |
|
|
| #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| # pragma GCC system_header |
| #endif |
|
|
| #if __has_feature(address_sanitizer) |
|
|
| extern "C" { |
| _LIBCPP_EXPORTED_FROM_ABI void |
| __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*); |
| _LIBCPP_EXPORTED_FROM_ABI void __sanitizer_annotate_double_ended_contiguous_container( |
| const void*, const void*, const void*, const void*, const void*, const void*); |
| _LIBCPP_EXPORTED_FROM_ABI int |
| __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*); |
| } |
|
|
| #endif |
|
|
| _LIBCPP_BEGIN_NAMESPACE_STD |
|
|
| |
| #if __has_feature(address_sanitizer) |
| # define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1 |
| #endif |
|
|
| #ifdef _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS |
| |
| |
| |
| template <class _Alloc> |
| struct __asan_annotate_container_with_allocator : true_type {}; |
| #endif |
|
|
| |
| |
| |
| |
| template <class _Allocator> |
| _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container( |
| const void* __first_storage, |
| const void* __last_storage, |
| const void* __first_old_contained, |
| const void* __last_old_contained, |
| const void* __first_new_contained, |
| const void* __last_new_contained) { |
| #if !__has_feature(address_sanitizer) |
| (void)__first_storage; |
| (void)__last_storage; |
| (void)__first_old_contained; |
| (void)__last_old_contained; |
| (void)__first_new_contained; |
| (void)__last_new_contained; |
| #else |
| if (__asan_annotate_container_with_allocator<_Allocator>::value && __first_storage != nullptr) |
| __sanitizer_annotate_double_ended_contiguous_container( |
| __first_storage, |
| __last_storage, |
| __first_old_contained, |
| __last_old_contained, |
| __first_new_contained, |
| __last_new_contained); |
| #endif |
| } |
|
|
| |
| |
| |
| |
| template <class _Allocator> |
| _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_container( |
| const void* __first_storage, |
| const void* __last_storage, |
| const void* __old_last_contained, |
| const void* __new_last_contained) { |
| #if !__has_feature(address_sanitizer) |
| (void)__first_storage; |
| (void)__last_storage; |
| (void)__old_last_contained; |
| (void)__new_last_contained; |
| #else |
| if (!__libcpp_is_constant_evaluated() && __asan_annotate_container_with_allocator<_Allocator>::value && |
| __first_storage != nullptr) |
| __sanitizer_annotate_contiguous_container( |
| __first_storage, __last_storage, __old_last_contained, __new_last_contained); |
| #endif |
| } |
|
|
| _LIBCPP_END_NAMESPACE_STD |
|
|
| #endif |
|
|