1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
10 #define ASAN_TESTING_H
12 #include "test_macros.h"
15 #if TEST_HAS_FEATURE(address_sanitizer)
16 extern "C" int __sanitizer_verify_contiguous_container
17 ( const void *beg
, const void *mid
, const void *end
);
19 template <typename T
, typename Alloc
>
20 TEST_CONSTEXPR
bool is_contiguous_container_asan_correct ( const std::vector
<T
, Alloc
> &c
)
22 if (std::__libcpp_is_constant_evaluated())
24 if (std::is_same
<Alloc
, std::allocator
<T
> >::value
&& c
.data() != NULL
)
25 return __sanitizer_verify_contiguous_container(
26 c
.data(), c
.data() + c
.size(), c
.data() + c
.capacity()) != 0;
30 template <typename T
, typename Alloc
>
31 TEST_CONSTEXPR
bool is_contiguous_container_asan_correct ( const std::vector
<T
, Alloc
> &)
35 #endif // TEST_HAS_FEATURE(address_sanitizer)
37 #if TEST_HAS_FEATURE(address_sanitizer) && _LIBCPP_CLANG_VER >= 1600
38 extern "C" int __sanitizer_verify_double_ended_contiguous_container(
39 const void* beg
, const void* con_beg
, const void* con_end
, const void* end
);
40 extern "C" bool __sanitizer_is_annotable(const void* address
, const unsigned long size
);
43 template <class T
, class Alloc
>
44 TEST_CONSTEXPR
bool is_double_ended_contiguous_container_asan_correct(const std::deque
<T
, Alloc
>& c
) {
45 if (TEST_IS_CONSTANT_EVALUATED
)
47 if (std::is_same
<Alloc
, std::allocator
<T
> >::value
)
48 return c
.__verify_asan_annotations();
53 template <class T
, class Alloc
>
54 TEST_CONSTEXPR
bool is_double_ended_contiguous_container_asan_correct(const std::deque
<T
, Alloc
>&) {
59 #endif // ASAN_TESTING_H