Skip to content

Commit f25f9e4

Browse files
authored
[libc++][NFC] Remove a bunch of redundant ASan existence checks (#128504)
There are currently lots of `_LIBCPP_HAS_ASAN` and `__libcpp_is_constant_evaluated()` checks which aren't needed, since it is centrally checked inside `__debug_utils/sanitizers.h`.
1 parent 2f54a84 commit f25f9e4

File tree

3 files changed

+6
-35
lines changed

3 files changed

+6
-35
lines changed

libcxx/include/__vector/vector.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -716,47 +716,32 @@ class vector {
716716
}
717717

718718
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {
719-
(void)__current_size;
720-
#if _LIBCPP_HAS_ASAN
721719
__annotate_contiguous_container(data() + capacity(), data() + __current_size);
722-
#endif
723720
}
724721

725722
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {
726-
#if _LIBCPP_HAS_ASAN
727723
__annotate_contiguous_container(data() + size(), data() + capacity());
728-
#endif
729724
}
730725

731726
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT {
732-
(void)__n;
733-
#if _LIBCPP_HAS_ASAN
734727
__annotate_contiguous_container(data() + size(), data() + size() + __n);
735-
#endif
736728
}
737729

738730
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
739-
(void)__old_size;
740-
#if _LIBCPP_HAS_ASAN
741731
__annotate_contiguous_container(data() + __old_size, data() + size());
742-
#endif
743732
}
744733

745734
struct _ConstructTransaction {
746735
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n)
747736
: __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
748-
#if _LIBCPP_HAS_ASAN
749737
__v_.__annotate_increase(__n);
750-
#endif
751738
}
752739

753740
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
754741
__v_.__end_ = __pos_;
755-
#if _LIBCPP_HAS_ASAN
756742
if (__pos_ != __new_end_) {
757743
__v_.__annotate_shrink(__new_end_ - __v_.__begin_);
758744
}
759-
#endif
760745
}
761746

762747
vector& __v_;

libcxx/include/string

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ private:
22232223
__annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {
22242224
(void)__old_mid;
22252225
(void)__new_mid;
2226-
# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2226+
# if _LIBCPP_INSTRUMENTED_WITH_ASAN
22272227
# if defined(__APPLE__)
22282228
// TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099)
22292229
if (!__is_long())
@@ -2234,34 +2234,19 @@ private:
22342234
}
22352235

22362236
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT {
2237-
(void)__current_size;
2238-
# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2239-
if (!__libcpp_is_constant_evaluated())
2240-
__annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1);
2241-
# endif
2237+
__annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1);
22422238
}
22432239

22442240
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT {
2245-
# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2246-
if (!__libcpp_is_constant_evaluated())
2247-
__annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1);
2248-
# endif
2241+
__annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1);
22492242
}
22502243

22512244
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT {
2252-
(void)__n;
2253-
# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2254-
if (!__libcpp_is_constant_evaluated())
2255-
__annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n);
2256-
# endif
2245+
__annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n);
22572246
}
22582247

22592248
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
2260-
(void)__old_size;
2261-
# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2262-
if (!__libcpp_is_constant_evaluated())
2263-
__annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1);
2264-
# endif
2249+
__annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1);
22652250
}
22662251

22672252
// Disable ASan annotations and enable them again when going out of scope. It is assumed that the string is in a valid

libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string.string_view.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
10+
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=9000000
1011

1112
// <string>
1213

0 commit comments

Comments
 (0)