Skip to content

Commit 2b3cdd6

Browse files
author
Tacet
authored
[ASan][libc++][NFC] refactor vector annotations arguments (#78322)
This commit simplifies ASan helper functions in `std::vector` by removing arguments which can be calculated later. Short term it improves readability of helper functions in `std::vector`. Long term it aims to help with a bigger refactor of container annotations.
1 parent fb79f80 commit 2b3cdd6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

libcxx/include/vector

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -832,12 +832,12 @@ private:
832832
// the documentation for __sanitizer_annotate_contiguous_container.
833833

834834
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_contiguous_container(
835-
const void* __beg, const void* __end, const void* __old_mid, const void* __new_mid) const {
836-
(void)__beg;
837-
(void)__end;
835+
const void* __old_mid, const void* __new_mid) const {
838836
(void)__old_mid;
839837
(void)__new_mid;
840838
#ifndef _LIBCPP_HAS_NO_ASAN
839+
const void* __beg = data();
840+
const void* __end = data() + capacity();
841841
if (!__libcpp_is_constant_evaluated() && __beg != nullptr &&
842842
__asan_annotate_container_with_allocator<_Allocator>::value)
843843
__sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
@@ -847,27 +847,27 @@ private:
847847
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {
848848
(void)__current_size;
849849
#ifndef _LIBCPP_HAS_NO_ASAN
850-
__annotate_contiguous_container(data(), data() + capacity(), data() + capacity(), data() + __current_size);
850+
__annotate_contiguous_container(data() + capacity(), data() + __current_size);
851851
#endif
852852
}
853853

854854
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {
855855
#ifndef _LIBCPP_HAS_NO_ASAN
856-
__annotate_contiguous_container(data(), data() + capacity(), data() + size(), data() + capacity());
856+
__annotate_contiguous_container(data() + size(), data() + capacity());
857857
#endif
858858
}
859859

860860
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT {
861861
(void)__n;
862862
#ifndef _LIBCPP_HAS_NO_ASAN
863-
__annotate_contiguous_container(data(), data() + capacity(), data() + size(), data() + size() + __n);
863+
__annotate_contiguous_container(data() + size(), data() + size() + __n);
864864
#endif
865865
}
866866

867867
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
868868
(void)__old_size;
869869
#ifndef _LIBCPP_HAS_NO_ASAN
870-
__annotate_contiguous_container(data(), data() + capacity(), data() + __old_size, data() + size());
870+
__annotate_contiguous_container(data() + __old_size, data() + size());
871871
#endif
872872
}
873873

0 commit comments

Comments
 (0)