[libcxx-commits] [libcxx] [libc++][NFC] Remove a bunch of redundant ASan existance checks (PR #128504)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Feb 24 04:44:07 PST 2025
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/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`.
>From d6396853973a7f501f782966d794eed5b07ab145 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Mon, 24 Feb 2025 13:42:37 +0100
Subject: [PATCH] [libc++][NFC] Remove a bunch of redundant ASan existance
checks
---
libcxx/include/__vector/vector.h | 15 ---------------
libcxx/include/string | 25 +++++--------------------
2 files changed, 5 insertions(+), 35 deletions(-)
diff --git a/libcxx/include/__vector/vector.h b/libcxx/include/__vector/vector.h
index ef796a8ed0a9e..9bd8949c17cec 100644
--- a/libcxx/include/__vector/vector.h
+++ b/libcxx/include/__vector/vector.h
@@ -682,47 +682,32 @@ class _LIBCPP_TEMPLATE_VIS vector {
}
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {
- (void)__current_size;
-#if _LIBCPP_HAS_ASAN
__annotate_contiguous_container(data() + capacity(), data() + __current_size);
-#endif
}
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {
-#if _LIBCPP_HAS_ASAN
__annotate_contiguous_container(data() + size(), data() + capacity());
-#endif
}
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT {
- (void)__n;
-#if _LIBCPP_HAS_ASAN
__annotate_contiguous_container(data() + size(), data() + size() + __n);
-#endif
}
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
- (void)__old_size;
-#if _LIBCPP_HAS_ASAN
__annotate_contiguous_container(data() + __old_size, data() + size());
-#endif
}
struct _ConstructTransaction {
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n)
: __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
-#if _LIBCPP_HAS_ASAN
__v_.__annotate_increase(__n);
-#endif
}
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
__v_.__end_ = __pos_;
-#if _LIBCPP_HAS_ASAN
if (__pos_ != __new_end_) {
__v_.__annotate_shrink(__new_end_ - __v_.__begin_);
}
-#endif
}
vector& __v_;
diff --git a/libcxx/include/string b/libcxx/include/string
index 46bf13a5c900f..ce0970f56ba1b 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -2141,7 +2141,7 @@ private:
__annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {
(void)__old_mid;
(void)__new_mid;
-# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
+# if _LIBCPP_INSTRUMENTED_WITH_ASAN
# if defined(__APPLE__)
// TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099)
if (!__is_long())
@@ -2152,34 +2152,19 @@ private:
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT {
- (void)__current_size;
-# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
- if (!__libcpp_is_constant_evaluated())
- __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1);
-# endif
+ __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1);
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT {
-# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
- if (!__libcpp_is_constant_evaluated())
- __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1);
-# endif
+ __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1);
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT {
- (void)__n;
-# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
- if (!__libcpp_is_constant_evaluated())
- __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n);
-# endif
+ __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n);
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
- (void)__old_size;
-# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
- if (!__libcpp_is_constant_evaluated())
- __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1);
-# endif
+ __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1);
}
// Disable ASan annotations and enable them again when going out of scope. It is assumed that the string is in a valid
More information about the libcxx-commits
mailing list