Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 +0000 | [diff] [blame] | 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 | |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 13 | #include <__config> |
Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 +0000 | [diff] [blame] | 14 | |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 15 | #ifndef _LIBCPP_HAS_NO_ASAN |
Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 +0000 | [diff] [blame] | 16 | extern "C" int __sanitizer_verify_contiguous_container |
| 17 | ( const void *beg, const void *mid, const void *end ); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 18 | |
Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 +0000 | [diff] [blame] | 19 | template <typename T, typename Alloc> |
| 20 | bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c ) |
| 21 | { |
Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 +0000 | [diff] [blame] | 22 | if ( std::is_same<Alloc, std::allocator<T> >::value && c.data() != NULL) |
Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 +0000 | [diff] [blame] | 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> |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 30 | bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c ) |
Marshall Clow | 1f50f2d | 2014-05-08 14:14:06 +0000 | [diff] [blame] | 31 | { |
| 32 | return true; |
| 33 | } |
| 34 | #endif |
| 35 | |
| 36 | |
Kostya Serebryany | 497f912 | 2014-09-02 23:43:38 +0000 | [diff] [blame] | 37 | #endif // ASAN_TESTING_H |