Assert equality between InternalGetArena() and InternalGetOwningArena().

PiperOrigin-RevId: 573291278
pull/14365/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent 8c8cbc43a7
commit 7eef3c906a
  1. 8
      src/google/protobuf/arena.h
  2. 1
      src/google/protobuf/repeated_field.h
  3. 1
      src/google/protobuf/repeated_ptr_field.h

@ -26,7 +26,7 @@ using type_info = ::type_info;
#include <typeinfo>
#endif
#include "absl/meta/type_traits.h"
#include "absl/log/absl_check.h"
#include "google/protobuf/arena_align.h"
#include "google/protobuf/port.h"
#include "google/protobuf/serial_arena.h"
@ -461,7 +461,9 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
// Provides access to protected GetOwningArena to generated messages. For
// internal use only.
template <typename T>
static Arena* InternalGetOwningArena(const T* p) {
static Arena* InternalGetOwningArena(T* p) {
ABSL_DCHECK_EQ(InternalHelper<T>::GetOwningArena(p),
InternalHelper<T>::GetArena(p));
return InternalHelper<T>::GetOwningArena(p);
}
@ -476,6 +478,8 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
// For internal use only.
template <typename T>
static Arena* InternalGetArena(T* p) {
ABSL_DCHECK_EQ(InternalHelper<T>::GetOwningArena(p),
InternalHelper<T>::GetArena(p));
return InternalHelper<T>::GetArena(p);
}

@ -333,6 +333,7 @@ class RepeatedField final
: rep()->arena;
}
// Swaps entire contents with "other". Should be called only if the caller can
// guarantee that both repeated fields are on the same arena or are on the
// heap. Swapping between different arenas is disallowed and caught by a

@ -1323,6 +1323,7 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase {
// Internal version of GetArena().
inline Arena* GetOwningArena() const;
// Implementations for ExtractSubrange(). The copying behavior must be
// included only if the type supports the necessary operations (e.g.,
// MergeFrom()), so we must resolve this at compile time. ExtractSubrange()

Loading…
Cancel
Save