1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef ASAN_TESTING_H
10 #define ASAN_TESTING_H
11 
12 #include "test_macros.h"
13 
14 #if TEST_HAS_FEATURE(address_sanitizer)
15 extern "C" int __sanitizer_verify_contiguous_container
16      ( const void *beg, const void *mid, const void *end );
17 
18 template <typename T, typename Alloc>
is_contiguous_container_asan_correct(const std::vector<T,Alloc> & c)19 bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
20 {
21     if ( std::is_same<Alloc, std::allocator<T> >::value && c.data() != NULL)
22         return __sanitizer_verify_contiguous_container (
23             c.data(), c.data() + c.size(), c.data() + c.capacity()) != 0;
24     return true;
25 }
26 
27 #else
28 template <typename T, typename Alloc>
is_contiguous_container_asan_correct(const std::vector<T,Alloc> &)29 bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &)
30 {
31     return true;
32 }
33 #endif
34 
35 
36 #endif  // ASAN_TESTING_H
37