Skip to content

Commit

Permalink
Add RAW_PTR_EXCLUSION to files in base/
Browse files Browse the repository at this point in the history
Add RAW_PTR_EXCLUSION to files in base/ where the rewriter could not automatically rewrite.

Change was generated by processing the output of the rewriter.

Bug: 1273182
Change-Id: I0e2083c172689261d9a7bc1ccde85a4366ed828c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4170100
Reviewed-by: Keishi Hattori <keishi@chromium.org>
Owners-Override: Keishi Hattori <keishi@chromium.org>
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Reviewed-by: Bartek Nowierski <bartekn@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1094319}
  • Loading branch information
Keishi Hattori authored and Chromium LUCI CQ committed Jan 19, 2023
1 parent 1df7789 commit 8a7e15d
Show file tree
Hide file tree
Showing 30 changed files with 173 additions and 46 deletions.
5 changes: 4 additions & 1 deletion base/check_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "base/check.h"
#include "base/dcheck_is_on.h"
#include "base/debug/debugging_buildflags.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/template_util.h"

// This header defines the (DP)CHECK_EQ etc. macros.
Expand Down Expand Up @@ -146,7 +147,9 @@ class BASE_EXPORT CheckOpResult {
char* v2_str);

private:
LogMessage* const log_message_ = nullptr;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION LogMessage* const log_message_ = nullptr;
};

// Helper macro for binary operators.
Expand Down
13 changes: 10 additions & 3 deletions base/containers/checked_iterators.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "base/check_op.h"
#include "base/containers/util.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "build/build_config.h"

namespace base {
Expand Down Expand Up @@ -207,9 +208,15 @@ class CheckedContiguousIterator {
CHECK_EQ(end_, other.end_);
}

const T* start_ = nullptr;
T* current_ = nullptr;
const T* end_ = nullptr;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #union, #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION const T* start_ = nullptr;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #union, #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION T* current_ = nullptr;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #union, #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION const T* end_ = nullptr;
};

template <typename T>
Expand Down
5 changes: 4 additions & 1 deletion base/containers/intrusive_heap_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/check_op.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/notreached.h"
#include "base/rand_util.h"
#include "base/test/bind.h"
Expand Down Expand Up @@ -526,7 +527,9 @@ void ValidateValueType() {
// the contract expected of the DefaultHeapHandleAccessor.
struct TestElement {
int key;
HeapHandle* handle;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #reinterpret-cast-trivial-type
RAW_PTR_EXCLUSION HeapHandle* handle;

// Make this a min-heap by return > instead of <.
bool operator<(const TestElement& other) const { return key > other.key; }
Expand Down
5 changes: 4 additions & 1 deletion base/memory/raw_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "base/allocator/partition_allocator/partition_alloc_buildflags.h"
#include "base/allocator/partition_allocator/partition_alloc_config.h"
#include "base/allocator/partition_allocator/partition_alloc_forward.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "build/build_config.h"
#include "build/buildflag.h"

Expand Down Expand Up @@ -1707,7 +1708,9 @@ class PA_TRIVIAL_ABI PA_GSL_POINTER raw_ptr {
return ptr;
}

T* wrapped_ptr_;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #union, #global-scope, #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION T* wrapped_ptr_;

template <typename U, typename V>
friend class raw_ptr;
Expand Down
5 changes: 4 additions & 1 deletion base/memory/safe_ref_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/weak_ptr.h"
#include "base/test/gtest_util.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand All @@ -25,7 +26,9 @@ struct WithWeak : BaseClass {
void Method() {}

int i = 1;
WithWeak* self{this};
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #union
RAW_PTR_EXCLUSION WithWeak* self{this};
base::WeakPtrFactory<WithWeak> factory{this};
};

Expand Down
5 changes: 4 additions & 1 deletion base/memory/scoped_refptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "base/check.h"
#include "base/compiler_specific.h"
#include "base/memory/raw_ptr_exclusion.h"

template <class T>
class scoped_refptr;
Expand Down Expand Up @@ -332,7 +333,9 @@ class TRIVIAL_ABI scoped_refptr {
}

protected:
T* ptr_ = nullptr;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #union, #addr-of, #global-scope
RAW_PTR_EXCLUSION T* ptr_ = nullptr;

private:
template <typename U>
Expand Down
5 changes: 4 additions & 1 deletion base/message_loop/message_pump_epoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "base/containers/stack_container.h"
#include "base/files/scoped_file.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_pump.h"
Expand Down Expand Up @@ -128,7 +129,9 @@ class BASE_EXPORT MessagePumpEpoll : public MessagePump,

// Null if Run() is not currently executing. Otherwise it's a pointer into the
// stack of the innermost nested Run() invocation.
RunState* run_state_ = nullptr;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #addr-of
RAW_PTR_EXCLUSION RunState* run_state_ = nullptr;

// Mapping of all file descriptors currently watched by this message pump.
// std::map was chosen because (1) the number of elements can vary widely,
Expand Down
5 changes: 4 additions & 1 deletion base/message_loop/message_pump_libevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/base_export.h"
#include "base/compiler_specific.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_pump.h"
#include "base/message_loop/message_pump_buildflags.h"
Expand Down Expand Up @@ -232,7 +233,9 @@ class BASE_EXPORT MessagePumpLibevent : public MessagePump,
#endif

// State for the current invocation of Run(). null if not running.
RunState* run_state_ = nullptr;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #addr-of
RAW_PTR_EXCLUSION RunState* run_state_ = nullptr;

// This flag is set if libevent has processed I/O events.
bool processed_io_events_ = false;
Expand Down
29 changes: 22 additions & 7 deletions base/metrics/field_trial_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/base_export.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/notreached.h"
#include "base/time/time.h"

Expand Down Expand Up @@ -149,7 +150,9 @@ struct FeatureParam<std::string> {
// GetFieldTrialParamValueByFeature() for more details.
BASE_EXPORT std::string Get() const;

const Feature* const feature;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #global-scope, #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION const Feature* const feature;
const char* const name;
const char* const default_value;
};
Expand All @@ -172,7 +175,9 @@ struct FeatureParam<double> {
// GetFieldTrialParamValueByFeature() for more details.
BASE_EXPORT double Get() const;

const Feature* const feature;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #global-scope, #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION const Feature* const feature;
const char* const name;
const double default_value;
};
Expand All @@ -195,7 +200,9 @@ struct FeatureParam<int> {
// GetFieldTrialParamValueByFeature() for more details.
BASE_EXPORT int Get() const;

const Feature* const feature;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #global-scope, #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION const Feature* const feature;
const char* const name;
const int default_value;
};
Expand All @@ -218,7 +225,9 @@ struct FeatureParam<bool> {
// GetFieldTrialParamValueByFeature() for more details.
BASE_EXPORT bool Get() const;

const Feature* const feature;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #global-scope, #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION const Feature* const feature;
const char* const name;
const bool default_value;
};
Expand All @@ -241,7 +250,9 @@ struct FeatureParam<base::TimeDelta> {
// GetFieldTrialParamValueByFeature() for more details.
BASE_EXPORT base::TimeDelta Get() const;

const Feature* const feature;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #global-scope, #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION const Feature* const feature;
const char* const name;
const base::TimeDelta default_value;
};
Expand Down Expand Up @@ -310,10 +321,14 @@ struct FeatureParam<Enum, true> {
return "";
}

const base::Feature* const feature;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #global-scope, #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION const base::Feature* const feature;
const char* const name;
const Enum default_value;
const Option* const options;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #global-scope, #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION const Option* const options;
const size_t option_count;
};

Expand Down
5 changes: 4 additions & 1 deletion base/path_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/synchronization/lock.h"
#include "build/build_config.h"

Expand Down Expand Up @@ -47,7 +48,9 @@ typedef std::unordered_map<int, FilePath> PathMap;
// providers claim overlapping keys.
struct Provider {
PathService::ProviderFunc func;
struct Provider* next;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #reinterpret-cast-trivial-type, #global-scope
RAW_PTR_EXCLUSION struct Provider* next;
#ifndef NDEBUG
int key_start;
int key_end;
Expand Down
6 changes: 5 additions & 1 deletion base/process/memory_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/memory/raw_ptr_exclusion.h"

#define _CRT_SECURE_NO_WARNINGS

#include "base/process/memory.h"
Expand Down Expand Up @@ -149,7 +151,9 @@ class OutOfMemoryTest : public testing::Test {
signed_test_size_(std::numeric_limits<ssize_t>::max()) {}

protected:
void* value_;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #addr-of
RAW_PTR_EXCLUSION void* value_;
size_t test_size_;
size_t insecure_test_size_;
ssize_t signed_test_size_;
Expand Down
5 changes: 4 additions & 1 deletion base/profiler/stack_sampling_profiler_test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/base_export.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/native_library.h"
#include "base/profiler/frame.h"
#include "base/profiler/sampling_profiler_thread_token.h"
Expand Down Expand Up @@ -50,7 +51,9 @@ class TargetThread : public PlatformThread::Delegate {

// Addresses near the start and end of a function.
struct FunctionAddressRange {
const void* start;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #in-out-param-ref
RAW_PTR_EXCLUSION const void* start;
raw_ptr<const void> end;
};

Expand Down
5 changes: 4 additions & 1 deletion base/profiler/unwinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <vector>

#include "base/base_export.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/profiler/frame.h"
#include "base/profiler/module_cache.h"
#include "base/profiler/register_context.h"
Expand Down Expand Up @@ -90,7 +91,9 @@ class BASE_EXPORT Unwinder {
ModuleCache* module_cache() const { return module_cache_; }

private:
ModuleCache* module_cache_ = nullptr;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION ModuleCache* module_cache_ = nullptr;
};

} // namespace base
Expand Down
5 changes: 4 additions & 1 deletion base/run_loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "base/gtest_prod_util.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/sequence_checker.h"
Expand Down Expand Up @@ -299,7 +300,9 @@ class BASE_EXPORT RunLoop {
// A cached reference of RunLoop::Delegate for the thread driven by this
// RunLoop for quick access without using TLS (also allows access to state
// from another sequence during Run(), ref. |sequence_checker_| below).
Delegate* const delegate_;
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #union, #global-scope
RAW_PTR_EXCLUSION Delegate* const delegate_;

const Type type_;

Expand Down
5 changes: 4 additions & 1 deletion base/strings/safe_sprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdint.h>
#include <stdlib.h>

#include "base/memory/raw_ptr_exclusion.h"
#include "build/build_config.h"

#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
Expand Down Expand Up @@ -197,7 +198,9 @@ struct Arg {
const char* str;

// A pointer to an arbitrary object.
const void* ptr;
// This field is not a raw_ptr<> because it was filtered by the rewriter
// for: #union
RAW_PTR_EXCLUSION const void* ptr;
};
const enum Type type;
};
Expand Down
5 changes: 4 additions & 1 deletion base/substring_set_matcher/substring_set_matcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "base/base_export.h"
#include "base/check_op.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/substring_set_matcher/matcher_string_pattern.h"

namespace base {
Expand Down Expand Up @@ -275,7 +276,9 @@ class BASE_EXPORT SubstringSetMatcher {
// Note that due to __attribute__((packed)) below, this pointer may be
// unaligned on 64-bit platforms, causing slightly less efficient
// access to it in some cases.
AhoCorasickEdge* edges;
// This field is not a raw_ptr<> because it was filtered by the rewriter
// for: #union
RAW_PTR_EXCLUSION AhoCorasickEdge* edges;

// Inline edge storage, used if edges_capacity_ == 0.
AhoCorasickEdge inline_edges[kNumInlineEdges];
Expand Down
6 changes: 5 additions & 1 deletion base/task/sequence_manager/time_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "base/base_export.h"
#include "base/check.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/task/common/lazy_now.h"
#include "base/task/sequence_manager/tasks.h"
#include "base/time/tick_clock.h"
Expand Down Expand Up @@ -58,7 +59,10 @@ class BASE_EXPORT TimeDomain : public TickClock {
private:
friend class internal::SequenceManagerImpl;

internal::SequenceManagerImpl* sequence_manager_ = nullptr; // Not owned.
// This field is not a raw_ptr<> because it was filtered by the rewriter for:
// #constexpr-ctor-field-initializer
RAW_PTR_EXCLUSION internal::SequenceManagerImpl* sequence_manager_ =
nullptr; // Not owned.
};

} // namespace sequence_manager
Expand Down
Loading

0 comments on commit 8a7e15d

Please sign in to comment.