Rewrite most `Foo* field_` pointer fields to `raw_ptr<Foo> field_`.

DO NOT REVERT (unless absolutely necessary)! Report build breaks to keishi@(APAC)/glazunov@(EMEA)/sebmarchand@(NA) as soon as you see them. Fixes are expected to be trivial.

This commit was generated automatically, by running the following script: tools/clang/rewrite_raw_ptr_fields/ on commit fe74bc434e5b7e92d13a328362fcb6df15d8847e

For more information, see MiraclePtr One Pager [1], the PSA at chromium-dev@ [2], and the raw_ptr documentation in //base/memory/

FYI This CL does not enable MiraclePtr protection and we expect no behavior change from this.


Binary-Size: Increase of around 500kb was approved for MiraclePtr
Include-Ci-Only-Tests: true
No-Tree-Checks: true
No-Presubmit: true
Bug: 1272324, 1073933
Change-Id: I05c86a83bbb4b3f4b017f361dd7f4e7437697f69
Commit-Queue: Keishi Hattori <>
Reviewed-by: Bartek Nowierski <>
Owners-Override: Bartek Nowierski <>
Cr-Commit-Position: refs/heads/main@{#945735}
GitOrigin-RevId: 0e45c020c43b1a9f6d2870ff7f92b30a2f03a458
diff --git a/reader.h b/reader.h
index a1eb01b..e6f03a9 100644
--- a/reader.h
+++ b/reader.h
@@ -10,6 +10,7 @@
 #include <map>
 #include "base/containers/span.h"
+#include "base/memory/raw_ptr.h"
 #include "components/cbor/cbor_export.h"
 #include "components/cbor/values.h"
 #include "third_party/abseil-cpp/absl/types/optional.h"
@@ -90,11 +91,11 @@
     // Used to report the number of bytes of input consumed. This suppresses the
     // |EXTRANEOUS_DATA| error case. May be nullptr.
-    size_t* num_bytes_consumed = nullptr;
+    raw_ptr<size_t> num_bytes_consumed = nullptr;
     // Used to report the specific error in the case that parsing fails. May be
     // nullptr;
-    DecoderError* error_code_out = nullptr;
+    raw_ptr<DecoderError> error_code_out = nullptr;
     // Controls the maximum depth of CBOR nesting that will be permitted. This
     // exists to control stack consumption during parsing.
diff --git a/writer.h b/writer.h
index 2eecbe8..ada13b1 100644
--- a/writer.h
+++ b/writer.h
@@ -10,6 +10,7 @@
 #include <vector>
+#include "base/memory/raw_ptr.h"
 #include "components/cbor/cbor_export.h"
 #include "components/cbor/values.h"
 #include "third_party/abseil-cpp/absl/types/optional.h"
@@ -111,7 +112,7 @@
   size_t GetNumUintBytes(uint64_t value);
   // Holds the encoded CBOR data.
-  std::vector<uint8_t>* encoded_cbor_;
+  raw_ptr<std::vector<uint8_t>> encoded_cbor_;
 }  // namespace cbor