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