1*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
2*0a6a1f1dSLionel Sambuc //
3*0a6a1f1dSLionel Sambuc // The LLVM Compiler Infrastructure
4*0a6a1f1dSLionel Sambuc //
5*0a6a1f1dSLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open
6*0a6a1f1dSLionel Sambuc // Source Licenses. See LICENSE.TXT for details.
7*0a6a1f1dSLionel Sambuc //
8*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
9*0a6a1f1dSLionel Sambuc
10*0a6a1f1dSLionel Sambuc #ifndef ASAN_TESTING_H
11*0a6a1f1dSLionel Sambuc #define ASAN_TESTING_H
12*0a6a1f1dSLionel Sambuc
13*0a6a1f1dSLionel Sambuc #include <__config>
14*0a6a1f1dSLionel Sambuc
15*0a6a1f1dSLionel Sambuc #ifndef _LIBCPP_HAS_NO_ASAN
16*0a6a1f1dSLionel Sambuc extern "C" int __sanitizer_verify_contiguous_container
17*0a6a1f1dSLionel Sambuc ( const void *beg, const void *mid, const void *end );
18*0a6a1f1dSLionel Sambuc
19*0a6a1f1dSLionel Sambuc template <typename T, typename Alloc>
is_contiguous_container_asan_correct(const std::vector<T,Alloc> & c)20*0a6a1f1dSLionel Sambuc bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
21*0a6a1f1dSLionel Sambuc {
22*0a6a1f1dSLionel Sambuc if ( std::is_same<Alloc, std::allocator<T> >::value && c.data() != NULL)
23*0a6a1f1dSLionel Sambuc return __sanitizer_verify_contiguous_container (
24*0a6a1f1dSLionel Sambuc c.data(), c.data() + c.size(), c.data() + c.capacity()) != 0;
25*0a6a1f1dSLionel Sambuc return true;
26*0a6a1f1dSLionel Sambuc }
27*0a6a1f1dSLionel Sambuc
28*0a6a1f1dSLionel Sambuc #else
29*0a6a1f1dSLionel Sambuc template <typename T, typename Alloc>
is_contiguous_container_asan_correct(const std::vector<T,Alloc> & c)30*0a6a1f1dSLionel Sambuc bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
31*0a6a1f1dSLionel Sambuc {
32*0a6a1f1dSLionel Sambuc return true;
33*0a6a1f1dSLionel Sambuc }
34*0a6a1f1dSLionel Sambuc #endif
35*0a6a1f1dSLionel Sambuc
36*0a6a1f1dSLionel Sambuc
37*0a6a1f1dSLionel Sambuc #endif // ASAN_TESTING_H
38