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 TEST_CONSTEXPR bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
20 {
21 if (std::__libcpp_is_constant_evaluated())
22 return true;
23 if (std::is_same<Alloc, std::allocator<T> >::value && c.data() != NULL)
24 return __sanitizer_verify_contiguous_container(
25 c.data(), c.data() + c.size(), c.data() + c.capacity()) != 0;
26 return true;
27 }
28
29 #else
30 template <typename T, typename Alloc>
is_contiguous_container_asan_correct(const std::vector<T,Alloc> &)31 TEST_CONSTEXPR bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &)
32 {
33 return true;
34 }
35 #endif
36
37
38 #endif // ASAN_TESTING_H
39