summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek Nowierski <bartekn@chromium.org>2024-05-01 21:54:20 -0700
committerchromeos-ci-prod <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>2024-05-02 04:20:27 -0700
commit20a9c387400a2572c04ac13ce0e332dec759b522 (patch)
tree6e8ea60747c49b7d7e02ceb74cb465b502f46c6a
parent6b032dbb9b9e36129d793bed9c82c55ada4c9f8f (diff)
downloadlibchrome-20a9c387400a2572c04ac13ce0e332dec759b522.tar.gz
raw_ptr: USE_HOOKABLE_RAW_PTR -> USE_RAW_PTR_HOOKABLE_IMPL
This is a no-op Change-Id: I4d6137785ee8d404d93fd105695e2adde0d52bb6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5508654 Reviewed-by: Kalvin Lee <kdlee@chromium.org> Auto-Submit: Bartek Nowierski <bartekn@chromium.org> Commit-Queue: Kalvin Lee <kdlee@chromium.org> Cr-Commit-Position: refs/heads/main@{#1295266} CrOS-Libchrome-Original-Commit: 301df1fd30831e19b9d52946ed2d757052ec9341
-rw-r--r--base/allocator/partition_allocator/partition_alloc.gni10
-rw-r--r--base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr.h35
-rw-r--r--base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_hookable_impl.h2
-rw-r--r--base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_unittest.cc24
4 files changed, 39 insertions, 32 deletions
diff --git a/base/allocator/partition_allocator/partition_alloc.gni b/base/allocator/partition_allocator/partition_alloc.gni
index db42414a89..517646314e 100644
--- a/base/allocator/partition_allocator/partition_alloc.gni
+++ b/base/allocator/partition_allocator/partition_alloc.gni
@@ -180,7 +180,7 @@ declare_args() {
# Use the version of raw_ptr<T> that allows the embedder to implement custom
# logic.
-use_hookable_raw_ptr = use_asan_backup_ref_ptr
+use_raw_ptr_hookable_impl = use_asan_backup_ref_ptr
declare_args() {
# - enable_backup_ref_ptr_slow_checks: enable additional safety checks that
@@ -272,7 +272,7 @@ if (!use_partition_alloc) {
use_raw_ptr_backup_ref_impl = false
use_asan_backup_ref_ptr = false
use_asan_unowned_ptr = false
- use_hookable_raw_ptr = false
+ use_raw_ptr_hookable_impl = false
enable_backup_ref_ptr_slow_checks = false
enable_dangling_raw_ptr_checks = false
enable_dangling_raw_ptr_feature_flag = false
@@ -342,14 +342,14 @@ assert(!enable_backup_ref_ptr_support || !use_asan_unowned_ptr,
# RawPtrHookableImpl and BackupRefPtr are mutually exclusive variants of
# raw_ptr.
assert(
- !use_hookable_raw_ptr || !enable_backup_ref_ptr_support,
+ !use_raw_ptr_hookable_impl || !enable_backup_ref_ptr_support,
"Both RawPtrHookableImpl and BackupRefPtr can't be enabled at the same " +
"time")
# RawPtrHookableImpl and AsanUnownedPtr are mutually exclusive variants of
# raw_ptr.
assert(
- !use_hookable_raw_ptr || !use_asan_unowned_ptr,
+ !use_raw_ptr_hookable_impl || !use_asan_unowned_ptr,
"Both RawPtrHookableImpl and AsanUnownedPtr can't be enabled at the same " +
"time")
@@ -365,7 +365,7 @@ assert(!use_asan_unowned_ptr || is_asan,
assert(build_with_chromium || !use_asan_backup_ref_ptr,
"AsanBackupRefPtr is not supported outside Chromium")
-assert(!use_asan_backup_ref_ptr || use_hookable_raw_ptr,
+assert(!use_asan_backup_ref_ptr || use_raw_ptr_hookable_impl,
"AsanBackupRefPtr requires RawPtrHookableImpl")
declare_args() {
diff --git a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr.h b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr.h
index 5bd9d91fec..d186bfbb62 100644
--- a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr.h
+++ b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr.h
@@ -49,7 +49,7 @@
#include "partition_alloc/pointers/raw_ptr_backup_ref_impl.h"
#elif BUILDFLAG(USE_ASAN_UNOWNED_PTR)
#include "partition_alloc/pointers/raw_ptr_asan_unowned_impl.h"
-#elif BUILDFLAG(USE_HOOKABLE_RAW_PTR)
+#elif BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL)
#include "partition_alloc/pointers/raw_ptr_hookable_impl.h"
#else
#include "partition_alloc/pointers/raw_ptr_noop_impl.h"
@@ -106,7 +106,8 @@ enum class RawPtrTraits : unsigned {
// instead.
kMayDangle = (1 << 0),
- // Disables any hooks, when building with BUILDFLAG(USE_HOOKABLE_RAW_PTR).
+ // Disables any hooks, when building with
+ // BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL).
//
// Internal use only.
kDisableHooks = (1 << 2),
@@ -275,7 +276,7 @@ using UnderlyingImplForTraits = internal::RawPtrAsanUnownedImpl<
RawPtrTraits::kAllowPtrArithmetic),
partition_alloc::internal::ContainsFlags(Traits, RawPtrTraits::kMayDangle)>;
-#elif BUILDFLAG(USE_HOOKABLE_RAW_PTR)
+#elif BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL)
template <RawPtrTraits Traits>
using UnderlyingImplForTraits = internal::RawPtrHookableImpl<
/*EnableHooks=*/!partition_alloc::internal::ContainsFlags(
@@ -362,8 +363,8 @@ class PA_TRIVIAL_ABI PA_GSL_POINTER raw_ptr {
// A non-trivial default ctor is required for complex implementations (e.g.
// BackupRefPtr), or even for NoOpImpl when zeroing is requested.
-#if BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) || \
- BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_HOOKABLE_RAW_PTR) || \
+#if BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) || \
+ BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL) || \
BUILDFLAG(RAW_PTR_ZERO_ON_CONSTRUCT)
PA_ALWAYS_INLINE constexpr raw_ptr() noexcept {
if constexpr (kZeroOnConstruct) {
@@ -376,7 +377,8 @@ class PA_TRIVIAL_ABI PA_GSL_POINTER raw_ptr {
PA_ALWAYS_INLINE constexpr raw_ptr() noexcept = default;
static_assert(!kZeroOnConstruct);
#endif // BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) ||
- // BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_HOOKABLE_RAW_PTR) ||
+ // BUILDFLAG(USE_ASAN_UNOWNED_PTR) ||
+ // BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL) ||
// BUILDFLAG(RAW_PTR_ZERO_ON_CONSTRUCT)
// A non-trivial copy ctor and assignment operator are required for complex
@@ -384,7 +386,7 @@ class PA_TRIVIAL_ABI PA_GSL_POINTER raw_ptr {
// these for NoOpImpl even when zeroing is requested; better to keep them
// trivial.
#if BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) || \
- BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_HOOKABLE_RAW_PTR)
+ BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL)
PA_ALWAYS_INLINE constexpr raw_ptr(const raw_ptr& p) noexcept
: wrapped_ptr_(Impl::Duplicate(p.wrapped_ptr_)) {
Impl::Trace(tracer_.owner_id(), p.wrapped_ptr_);
@@ -408,13 +410,14 @@ class PA_TRIVIAL_ABI PA_GSL_POINTER raw_ptr {
PA_ALWAYS_INLINE raw_ptr(const raw_ptr&) noexcept = default;
PA_ALWAYS_INLINE raw_ptr& operator=(const raw_ptr&) noexcept = default;
#endif // BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) ||
- // BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_HOOKABLE_RAW_PTR)
+ // BUILDFLAG(USE_ASAN_UNOWNED_PTR) ||
+ // BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL)
// A non-trivial move ctor and assignment operator are required for complex
// implementations (e.g. BackupRefPtr), or even for NoOpImpl when zeroing is
// requested.
-#if BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) || \
- BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_HOOKABLE_RAW_PTR) || \
+#if BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) || \
+ BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL) || \
BUILDFLAG(RAW_PTR_ZERO_ON_MOVE)
PA_ALWAYS_INLINE constexpr raw_ptr(raw_ptr&& p) noexcept {
wrapped_ptr_ = p.wrapped_ptr_;
@@ -444,13 +447,14 @@ class PA_TRIVIAL_ABI PA_GSL_POINTER raw_ptr {
PA_ALWAYS_INLINE raw_ptr& operator=(raw_ptr&&) noexcept = default;
static_assert(!kZeroOnMove);
#endif // BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) ||
- // BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_HOOKABLE_RAW_PTR) ||
+ // BUILDFLAG(USE_ASAN_UNOWNED_PTR) ||
+ // BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL) ||
// BUILDFLAG(RAW_PTR_ZERO_ON_MOVE)
// A non-trivial default dtor is required for complex implementations (e.g.
// BackupRefPtr), or even for NoOpImpl when zeroing is requested.
-#if BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) || \
- BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_HOOKABLE_RAW_PTR) || \
+#if BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) || \
+ BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL) || \
BUILDFLAG(RAW_PTR_ZERO_ON_DESTRUCT)
PA_ALWAYS_INLINE PA_CONSTEXPR_DTOR ~raw_ptr() noexcept {
Impl::ReleaseWrappedPtr(wrapped_ptr_);
@@ -464,7 +468,8 @@ class PA_TRIVIAL_ABI PA_GSL_POINTER raw_ptr {
PA_ALWAYS_INLINE ~raw_ptr() noexcept = default;
static_assert(!kZeroOnDestruct);
#endif // BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) ||
- // BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_HOOKABLE_RAW_PTR) ||
+ // BUILDFLAG(USE_ASAN_UNOWNED_PTR) ||
+ // BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL) ||
// BUILDFLAG(RAW_PTR_ZERO_ON_DESTRUCT)
// Cross-kind copy constructor.
@@ -481,7 +486,7 @@ class PA_TRIVIAL_ABI PA_GSL_POINTER raw_ptr {
// Limit cross-kind conversions only to cases where `kMayDangle` gets added,
// because that's needed for ExtractAsDangling() and Unretained(Ref)Wrapper.
// Use a static_assert, instead of disabling via SFINAE, so that the
- // compiler catches other conversions. Otherwise the implicit
+ // compiler catches other conversions. Otherwise the implicits
// `raw_ptr<T> -> T* -> raw_ptr<>` route will be taken.
static_assert(Traits == (raw_ptr<T, PassedTraits>::Traits |
RawPtrTraits::kMayDangle));
diff --git a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_hookable_impl.h b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_hookable_impl.h
index 6d38222ac9..d0f1ed8cdc 100644
--- a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_hookable_impl.h
+++ b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_hookable_impl.h
@@ -14,7 +14,7 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#include "partition_alloc/partition_alloc_forward.h"
-#if !BUILDFLAG(USE_HOOKABLE_RAW_PTR)
+#if !BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL)
#error "Included under wrong build option"
#endif
diff --git a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_unittest.cc
index 2d4d1597a8..657a334d7f 100644
--- a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_unittest.cc
+++ b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_unittest.cc
@@ -69,8 +69,9 @@ static_assert(sizeof(raw_ptr<std::string>) == sizeof(std::string*),
"raw_ptr shouldn't add memory overhead");
#endif
-#if !BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) && \
- !BUILDFLAG(USE_ASAN_UNOWNED_PTR) && !BUILDFLAG(USE_HOOKABLE_RAW_PTR) && \
+#if !BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) && \
+ !BUILDFLAG(USE_ASAN_UNOWNED_PTR) && \
+ !BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL) && \
!BUILDFLAG(RAW_PTR_ZERO_ON_MOVE) && !BUILDFLAG(RAW_PTR_ZERO_ON_DESTRUCT)
// |is_trivially_copyable| assertion means that arrays/vectors of raw_ptr can
// be copied by memcpy.
@@ -82,13 +83,14 @@ static_assert(std::is_trivially_copyable_v<raw_ptr<std::string>>,
"raw_ptr should be trivially copyable");
#endif // !BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) &&
// !BUILDFLAG(USE_ASAN_UNOWNED_PTR) &&
- // !BUILDFLAG(USE_HOOKABLE_RAW_PTR) &&
+ // !BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL) &&
// !BUILDFLAG(RAW_PTR_ZERO_ON_MOVE) &&
// !BUILDFLAG(RAW_PTR_ZERO_ON_DESTRUCT)
-#if !BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) && \
- !BUILDFLAG(USE_ASAN_UNOWNED_PTR) && !BUILDFLAG(USE_HOOKABLE_RAW_PTR) && \
- !BUILDFLAG(RAW_PTR_ZERO_ON_CONSTRUCT) && \
+#if !BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) && \
+ !BUILDFLAG(USE_ASAN_UNOWNED_PTR) && \
+ !BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL) && \
+ !BUILDFLAG(RAW_PTR_ZERO_ON_CONSTRUCT) && \
!BUILDFLAG(RAW_PTR_ZERO_ON_DESTRUCT)
// |is_trivially_default_constructible| assertion helps retain implicit default
// constructors when raw_ptr is used as a union field. Example of an error
@@ -110,7 +112,7 @@ static_assert(std::is_trivially_default_constructible_v<raw_ptr<std::string>>,
"raw_ptr should be trivially default constructible");
#endif // !BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) &&
// !BUILDFLAG(USE_ASAN_UNOWNED_PTR) &&
- // !BUILDFLAG(USE_HOOKABLE_RAW_PTR) &&
+ // !BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL) &&
// !BUILDFLAG(RAW_PTR_ZERO_ON_CONSTRUCT) &&
// !BUILDFLAG(RAW_PTR_ZERO_ON_DESTRUCT)
@@ -1336,8 +1338,8 @@ TEST_F(RawPtrTest, TrivialRelocability) {
RawPtrCountingImpl::ClearCounters();
size_t number_of_cleared_elements = vector.size();
vector.clear();
-#if BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) || \
- BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_HOOKABLE_RAW_PTR) || \
+#if BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) || \
+ BUILDFLAG(USE_ASAN_UNOWNED_PTR) || BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL) || \
BUILDFLAG(RAW_PTR_ZERO_ON_DESTRUCT)
EXPECT_EQ((int)number_of_cleared_elements,
RawPtrCountingImpl::release_wrapped_ptr_cnt);
@@ -2432,7 +2434,7 @@ TEST_F(BackupRefPtrTest, RawPtrTraits_DisableBRP) {
#endif // BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL) &&
// !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
-#if BUILDFLAG(USE_HOOKABLE_RAW_PTR)
+#if BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL)
namespace {
#define FOR_EACH_RAW_PTR_OPERATION(F) \
@@ -2574,7 +2576,7 @@ TEST_F(HookableRawPtrImplTest, CrossKindCopyConstruction) {
EXPECT_EQ(CountingHooks::Get()->unsafely_unwrap_for_duplication_count, 1u);
}
-#endif // BUILDFLAG(USE_HOOKABLE_RAW_PTR)
+#endif // BUILDFLAG(USE_RAW_PTR_HOOKABLE_IMPL)
TEST(DanglingPtrTest, DetectAndReset) {
auto instrumentation = test::DanglingPtrInstrumentation::Create();