Internal changes

PiperOrigin-RevId: 494853699
pull/11215/head
Mike Kruskal 2 years ago committed by Copybara-Service
parent 0ef2e548ad
commit 3cdee9a70c
  1. 45
      src/google/protobuf/arena.cc
  2. 4
      src/google/protobuf/arena.h
  3. 8
      src/google/protobuf/arena_align.h
  4. 9
      src/google/protobuf/arena_cleanup.h
  5. 20
      src/google/protobuf/arena_impl.h
  6. 2
      src/google/protobuf/arena_test_util.cc
  7. 6
      src/google/protobuf/arena_test_util.h
  8. 4
      src/google/protobuf/arena_unittest.cc
  9. 6
      src/google/protobuf/arenastring.cc
  10. 8
      src/google/protobuf/arenastring.h
  11. 2
      src/google/protobuf/arenastring_unittest.cc
  12. 4
      src/google/protobuf/arenaz_sampler_test.cc
  13. 139
      src/google/protobuf/descriptor.cc
  14. 13
      src/google/protobuf/descriptor.h
  15. 64
      src/google/protobuf/descriptor_database.cc
  16. 2
      src/google/protobuf/descriptor_database.h
  17. 1
      src/google/protobuf/descriptor_database_unittest.cc
  18. 19
      src/google/protobuf/descriptor_unittest.cc
  19. 4
      src/google/protobuf/dynamic_message.cc
  20. 8
      src/google/protobuf/dynamic_message.h
  21. 1
      src/google/protobuf/dynamic_message_unittest.cc
  22. 3
      src/google/protobuf/explicitly_constructed.h
  23. 198
      src/google/protobuf/extension_set.cc
  24. 12
      src/google/protobuf/extension_set.h
  25. 32
      src/google/protobuf/extension_set_heavy.cc
  26. 2
      src/google/protobuf/extension_set_inl.h
  27. 1
      src/google/protobuf/extension_set_unittest.cc
  28. 2
      src/google/protobuf/generated_message_bases.cc
  29. 178
      src/google/protobuf/generated_message_reflection.cc
  30. 18
      src/google/protobuf/generated_message_reflection.h
  31. 4
      src/google/protobuf/generated_message_reflection_unittest.cc
  32. 24
      src/google/protobuf/generated_message_tctable_gen.cc
  33. 2
      src/google/protobuf/generated_message_tctable_impl.h
  34. 38
      src/google/protobuf/generated_message_tctable_lite.cc
  35. 2
      src/google/protobuf/generated_message_tctable_lite_test.cc
  36. 8
      src/google/protobuf/generated_message_util.cc
  37. 2
      src/google/protobuf/inlined_string_field.h
  38. 2
      src/google/protobuf/inlined_string_field_unittest.cc
  39. 9
      src/google/protobuf/lazy_field_lite.cc
  40. 2
      src/google/protobuf/lite_unittest.cc
  41. 44
      src/google/protobuf/map.h
  42. 12
      src/google/protobuf/map_field.cc
  43. 43
      src/google/protobuf/map_field.h
  44. 4
      src/google/protobuf/map_field_inl.h
  45. 2
      src/google/protobuf/map_field_lite.h
  46. 2
      src/google/protobuf/map_field_test.cc
  47. 29
      src/google/protobuf/map_test.inc
  48. 1
      src/google/protobuf/map_test_util_impl.h
  49. 42
      src/google/protobuf/message.cc
  50. 14
      src/google/protobuf/message.h
  51. 45
      src/google/protobuf/message_lite.cc
  52. 10
      src/google/protobuf/message_lite.h
  53. 8
      src/google/protobuf/message_unittest.inc
  54. 8
      src/google/protobuf/no_field_presence_test.cc
  55. 30
      src/google/protobuf/parse_context.cc
  56. 10
      src/google/protobuf/port_def.inc
  57. 8
      src/google/protobuf/proto3_arena_unittest.cc
  58. 6
      src/google/protobuf/reflection_internal.h
  59. 18
      src/google/protobuf/reflection_ops.cc
  60. 1
      src/google/protobuf/reflection_ops_unittest.cc
  61. 4
      src/google/protobuf/reflection_tester.cc
  62. 1
      src/google/protobuf/repeated_field.cc
  63. 52
      src/google/protobuf/repeated_field.h
  64. 4
      src/google/protobuf/repeated_field_reflection_unittest.cc
  65. 8
      src/google/protobuf/repeated_field_unittest.cc
  66. 14
      src/google/protobuf/repeated_ptr_field.cc
  67. 100
      src/google/protobuf/repeated_ptr_field.h
  68. 2
      src/google/protobuf/test_util.h
  69. 4
      src/google/protobuf/test_util.inc
  70. 4
      src/google/protobuf/test_util2.h
  71. 1
      src/google/protobuf/test_util_lite.cc
  72. 61
      src/google/protobuf/text_format.cc
  73. 6
      src/google/protobuf/text_format_unittest.cc
  74. 4
      src/google/protobuf/unknown_field_set.cc
  75. 4
      src/google/protobuf/unknown_field_set.h
  76. 1
      src/google/protobuf/unknown_field_set_unittest.cc
  77. 27
      src/google/protobuf/wire_format.cc
  78. 2
      src/google/protobuf/wire_format.h
  79. 11
      src/google/protobuf/wire_format_lite.cc
  80. 8
      src/google/protobuf/wire_format_lite.h
  81. 4
      src/google/protobuf/wire_format_unittest.inc

@ -93,8 +93,8 @@ static SerialArena::Memory AllocateMemory(const AllocationPolicy* policy_ptr,
size = policy.start_block_size;
}
// Verify that min_bytes + kBlockHeaderSize won't overflow.
GOOGLE_CHECK_LE(min_bytes,
std::numeric_limits<size_t>::max() - SerialArena::kBlockHeaderSize);
GOOGLE_ABSL_CHECK_LE(min_bytes, std::numeric_limits<size_t>::max() -
SerialArena::kBlockHeaderSize);
size = std::max(size, SerialArena::kBlockHeaderSize + min_bytes);
void* mem;
@ -139,7 +139,7 @@ SerialArena::SerialArena(ArenaBlock* b, ThreadSafeArena& parent)
head_{b},
space_allocated_{b->size},
parent_{parent} {
GOOGLE_DCHECK(!b->IsSentry());
GOOGLE_ABSL_DCHECK(!b->IsSentry());
}
// It is guaranteed that this is the first SerialArena. Use sentry block.
@ -168,7 +168,8 @@ void SerialArena::Init(ArenaBlock* b, size_t offset) {
}
SerialArena* SerialArena::New(Memory mem, ThreadSafeArena& parent) {
GOOGLE_DCHECK_LE(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize, mem.size);
GOOGLE_ABSL_DCHECK_LE(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize,
mem.size);
ThreadSafeArenaStats::RecordAllocateStats(parent.arena_stats_.MutableStats(),
/*used=*/0, /*allocated=*/mem.size,
/*wasted=*/0);
@ -277,7 +278,7 @@ void SerialArena::CleanupList() {
do {
char* limit = b->Limit();
char* it = reinterpret_cast<char*>(b->cleanup_nodes);
GOOGLE_DCHECK(!b->IsSentry() || it == limit);
GOOGLE_ABSL_DCHECK(!b->IsSentry() || it == limit);
while (it < limit) {
it += cleanup::DestroyNode(it);
}
@ -350,7 +351,7 @@ class ThreadSafeArena::SerialArenaChunk {
return Layout(capacity()).Slice<kIds>(ptr()).first(safe_size());
}
std::atomic<void*>& id(uint32_t i) {
GOOGLE_DCHECK_LT(i, capacity());
GOOGLE_ABSL_DCHECK_LT(i, capacity());
return Layout(capacity()).Pointer<kIds>(ptr())[i];
}
@ -362,11 +363,11 @@ class ThreadSafeArena::SerialArenaChunk {
return Layout(capacity()).Slice<kArenas>(ptr()).first(safe_size());
}
const std::atomic<SerialArena*>& arena(uint32_t i) const {
GOOGLE_DCHECK_LT(i, capacity());
GOOGLE_ABSL_DCHECK_LT(i, capacity());
return Layout(capacity()).Pointer<kArenas>(ptr())[i];
}
std::atomic<SerialArena*>& arena(uint32_t i) {
GOOGLE_DCHECK_LT(i, capacity());
GOOGLE_ABSL_DCHECK_LT(i, capacity());
return Layout(capacity()).Pointer<kArenas>(ptr())[i];
}
@ -473,7 +474,7 @@ ThreadSafeArena::ThreadSafeArena(void* mem, size_t size,
}
ArenaBlock* ThreadSafeArena::FirstBlock(void* buf, size_t size) {
GOOGLE_DCHECK_EQ(reinterpret_cast<uintptr_t>(buf) & 7, 0u);
GOOGLE_ABSL_DCHECK_EQ(reinterpret_cast<uintptr_t>(buf) & 7, 0u);
if (buf == nullptr || size <= kBlockHeaderSize) {
return SentryArenaBlock();
}
@ -486,7 +487,7 @@ ArenaBlock* ThreadSafeArena::FirstBlock(void* buf, size_t size,
const AllocationPolicy& policy) {
if (policy.IsDefault()) return FirstBlock(buf, size);
GOOGLE_DCHECK_EQ(reinterpret_cast<uintptr_t>(buf) & 7, 0u);
GOOGLE_ABSL_DCHECK_EQ(reinterpret_cast<uintptr_t>(buf) & 7, 0u);
SerialArena::Memory mem;
if (buf == nullptr || size < kBlockHeaderSize + kAllocPolicySize) {
@ -508,26 +509,26 @@ void ThreadSafeArena::InitializeWithPolicy(const AllocationPolicy& policy) {
#ifndef NDEBUG
const uint64_t old_alloc_policy = alloc_policy_.get_raw();
// If there was a policy (e.g., in Reset()), make sure flags were preserved.
#define GOOGLE_DCHECK_POLICY_FLAGS_() \
if (old_alloc_policy > 3) \
GOOGLE_CHECK_EQ(old_alloc_policy & 3, alloc_policy_.get_raw() & 3)
#define GOOGLE_ABSL_DCHECK_POLICY_FLAGS_() \
if (old_alloc_policy > 3) \
GOOGLE_ABSL_CHECK_EQ(old_alloc_policy & 3, alloc_policy_.get_raw() & 3)
#else
#define GOOGLE_DCHECK_POLICY_FLAGS_()
#define GOOGLE_ABSL_DCHECK_POLICY_FLAGS_()
#endif // NDEBUG
// We ensured enough space so this cannot fail.
void* p;
if (!first_arena_.MaybeAllocateAligned(kAllocPolicySize, &p)) {
GOOGLE_LOG(FATAL) << "MaybeAllocateAligned cannot fail here.";
GOOGLE_ABSL_LOG(FATAL) << "MaybeAllocateAligned cannot fail here.";
return;
}
new (p) AllocationPolicy{policy};
// Low bits store flags, so they mustn't be overwritten.
GOOGLE_DCHECK_EQ(0, reinterpret_cast<uintptr_t>(p) & 3);
GOOGLE_ABSL_DCHECK_EQ(0, reinterpret_cast<uintptr_t>(p) & 3);
alloc_policy_.set_policy(reinterpret_cast<AllocationPolicy*>(p));
GOOGLE_DCHECK_POLICY_FLAGS_();
GOOGLE_ABSL_DCHECK_POLICY_FLAGS_();
#undef GOOGLE_DCHECK_POLICY_FLAGS_
#undef GOOGLE_ABSL_DCHECK_POLICY_FLAGS_
}
uint64_t ThreadSafeArena::GetNextLifeCycleId() {
@ -647,10 +648,10 @@ SerialArena::Memory ThreadSafeArena::Free(size_t* space_allocated) {
// necessary to Free and we should revisit this. (b/247560530)
for (auto it = span.rbegin(); it != span.rend(); ++it) {
SerialArena* serial = it->load(std::memory_order_relaxed);
GOOGLE_DCHECK_NE(serial, nullptr);
GOOGLE_ABSL_DCHECK_NE(serial, nullptr);
// Always frees the first block of "serial" as it cannot be user-provided.
SerialArena::Memory mem = serial->Free(deallocator);
GOOGLE_DCHECK_NE(mem.ptr, nullptr);
GOOGLE_ABSL_DCHECK_NE(mem.ptr, nullptr);
deallocator(mem);
}
@ -794,7 +795,7 @@ void ThreadSafeArena::CleanupList() {
// and required not to break inter-object dependencies. (b/247560530)
for (auto it = span.rbegin(); it != span.rend(); ++it) {
SerialArena* serial = it->load(std::memory_order_relaxed);
GOOGLE_DCHECK_NE(serial, nullptr);
GOOGLE_ABSL_DCHECK_NE(serial, nullptr);
serial->CleanupList();
}
});
@ -817,7 +818,7 @@ SerialArena* ThreadSafeArena::GetSerialArenaFallback(size_t n) {
for (uint32_t i = 0; i < ids.size(); ++i) {
if (ids[i].load(std::memory_order_relaxed) == id) {
serial = chunk->arena(i).load(std::memory_order_relaxed);
GOOGLE_DCHECK_NE(serial, nullptr);
GOOGLE_ABSL_DCHECK_NE(serial, nullptr);
break;
}
}

@ -316,7 +316,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
"CreateArray requires a trivially constructible type");
static_assert(std::is_trivially_destructible<T>::value,
"CreateArray requires a trivially destructible type");
GOOGLE_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T))
GOOGLE_ABSL_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T))
<< "Requested size is too large to fit into size_t.";
if (arena == nullptr) {
return static_cast<T*>(::operator new[](num_elements * sizeof(T)));
@ -600,7 +600,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
// type has a trivial constructor.
template <typename T>
PROTOBUF_NDEBUG_INLINE T* CreateInternalRawArray(size_t num_elements) {
GOOGLE_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T))
GOOGLE_ABSL_CHECK_LE(num_elements, std::numeric_limits<size_t>::max() / sizeof(T))
<< "Requested size is too large to fit into size_t.";
// We count on compiler to realize that if sizeof(T) is a multiple of
// 8 AlignUpTo can be elided.

@ -104,7 +104,7 @@ struct ArenaAlignDefault {
// Address sanitizer enabled alignment check
template <typename T>
static T* CheckAligned(T* ptr) {
GOOGLE_DCHECK(IsAligned(ptr)) << static_cast<void*>(ptr);
GOOGLE_ABSL_DCHECK(IsAligned(ptr)) << static_cast<void*>(ptr);
return ptr;
}
};
@ -138,15 +138,15 @@ struct ArenaAlign {
// Address sanitizer enabled alignment check
template <typename T>
T* CheckAligned(T* ptr) const {
GOOGLE_DCHECK(IsAligned(ptr)) << static_cast<void*>(ptr);
GOOGLE_ABSL_DCHECK(IsAligned(ptr)) << static_cast<void*>(ptr);
return ptr;
}
};
inline ArenaAlign ArenaAlignAs(size_t align) {
// align must be a non zero power of 2 >= 8
GOOGLE_DCHECK_NE(align, 0);
GOOGLE_DCHECK(absl::has_single_bit(align)) << "Invalid alignment " << align;
GOOGLE_ABSL_DCHECK_NE(align, 0);
GOOGLE_ABSL_DCHECK(absl::has_single_bit(align)) << "Invalid alignment " << align;
return ArenaAlign{align};
}

@ -35,8 +35,9 @@
#include <cstdint>
#include <string>
#include "google/protobuf/stubs/logging.h"
#include "absl/base/attributes.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/cord.h"
@ -91,7 +92,7 @@ inline ABSL_ATTRIBUTE_ALWAYS_INLINE void CreateNode(Tag tag, void* pos,
void (*destructor)(void*)) {
auto elem = reinterpret_cast<uintptr_t>(elem_raw);
if (EnableSpecializedTags()) {
GOOGLE_DCHECK_EQ(elem & 3, 0ULL); // Must be aligned
GOOGLE_ABSL_DCHECK_EQ(elem & 3, 0ULL); // Must be aligned
switch (tag) {
case Tag::kString: {
TaggedNode n = {elem | static_cast<uintptr_t>(Tag::kString)};
@ -186,7 +187,7 @@ inline ABSL_ATTRIBUTE_ALWAYS_INLINE Tag Type(void* raw) {
case Tag::kCord:
return Tag::kCord;
default:
GOOGLE_LOG(FATAL) << "Corrupted cleanup tag: " << (elem & 0x7ULL);
GOOGLE_ABSL_LOG(FATAL) << "Corrupted cleanup tag: " << (elem & 0x7ULL);
return Tag::kDynamic;
}
}
@ -203,7 +204,7 @@ inline ABSL_ATTRIBUTE_ALWAYS_INLINE size_t Size(Tag tag) {
case Tag::kCord:
return sizeof(TaggedNode);
default:
GOOGLE_LOG(FATAL) << "Corrupted cleanup tag: " << static_cast<int>(tag);
GOOGLE_ABSL_LOG(FATAL) << "Corrupted cleanup tag: " << static_cast<int>(tag);
return sizeof(DynamicNode);
}
}

@ -41,8 +41,8 @@
#include <typeinfo>
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/base/attributes.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/numeric/bits.h"
#include "absl/synchronization/mutex.h"
#include "google/protobuf/arena_allocation_policy.h"
@ -92,11 +92,11 @@ struct ArenaBlock {
ArenaBlock(ArenaBlock* next, size_t size)
: next(next), cleanup_nodes(nullptr), size(size) {
GOOGLE_DCHECK_GT(size, sizeof(ArenaBlock));
GOOGLE_ABSL_DCHECK_GT(size, sizeof(ArenaBlock));
}
char* Pointer(size_t n) {
GOOGLE_DCHECK_LE(n, size);
GOOGLE_ABSL_DCHECK_LE(n, size);
return reinterpret_cast<char*>(this) + n;
}
char* Limit() { return Pointer(size & static_cast<size_t>(-8)); }
@ -172,8 +172,8 @@ class PROTOBUF_EXPORT SerialArena {
// from it.
template <AllocationClient alloc_client = AllocationClient::kDefault>
void* AllocateAligned(size_t n) {
GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
GOOGLE_DCHECK_GE(limit_, ptr());
GOOGLE_ABSL_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
GOOGLE_ABSL_DCHECK_GE(limit_, ptr());
if (alloc_client == AllocationClient::kArray) {
if (void* res = TryAllocateFromCachedBlock(n)) {
@ -248,8 +248,8 @@ class PROTOBUF_EXPORT SerialArena {
public:
// Allocate space if the current region provides enough space.
bool MaybeAllocateAligned(size_t n, void** out) {
GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
GOOGLE_DCHECK_GE(limit_, ptr());
GOOGLE_ABSL_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
GOOGLE_ABSL_DCHECK_GE(limit_, ptr());
if (PROTOBUF_PREDICT_FALSE(!HasSpace(n))) return false;
*out = AllocateFromExisting(n);
return true;
@ -260,7 +260,7 @@ class PROTOBUF_EXPORT SerialArena {
// and the memory returned is uninitialized.
template <typename T>
PROTOBUF_ALWAYS_INLINE void* MaybeAllocateWithCleanup() {
GOOGLE_DCHECK_GE(limit_, ptr());
GOOGLE_ABSL_DCHECK_GE(limit_, ptr());
static_assert(!std::is_trivially_destructible<T>::value,
"This function is only for non-trivial types.");
@ -302,7 +302,7 @@ class PROTOBUF_EXPORT SerialArena {
PROTOBUF_UNPOISON_MEMORY_REGION(ptr(), n);
void* ret = internal::AlignTo(ptr(), align);
set_ptr(ptr() + n);
GOOGLE_DCHECK_GE(limit_, ptr());
GOOGLE_ABSL_DCHECK_GE(limit_, ptr());
AddCleanupFromExisting(ret, destructor);
return ret;
}
@ -314,7 +314,7 @@ class PROTOBUF_EXPORT SerialArena {
PROTOBUF_UNPOISON_MEMORY_REGION(limit_ - n, n);
limit_ -= n;
GOOGLE_DCHECK_GE(limit_, ptr());
GOOGLE_ABSL_DCHECK_GE(limit_, ptr());
cleanup::CreateNode(tag, limit_, elem, destructor);
}

@ -33,7 +33,7 @@
#include "google/protobuf/stubs/logging.h"
#define EXPECT_EQ GOOGLE_CHECK_EQ
#define EXPECT_EQ GOOGLE_ABSL_CHECK_EQ
namespace google {
namespace protobuf {

@ -70,7 +70,7 @@ void TestParseCorruptedString(const T& message) {
}
// This next line is a low bar. But getting through the test without crashing
// due to use-after-free or other bugs is a big part of what we're checking.
GOOGLE_CHECK_GT(success_count, 0);
GOOGLE_ABSL_CHECK_GT(success_count, 0);
}
namespace internal {
@ -105,8 +105,8 @@ class ArenaHolder {
explicit ArenaHolder(Arena* arena)
: field_(Arena::CreateMessage<T>(arena)),
owned_by_arena_(arena != nullptr) {
GOOGLE_DCHECK(google::protobuf::Arena::is_arena_constructable<T>::value);
GOOGLE_DCHECK(google::protobuf::Arena::is_destructor_skippable<T>::value);
GOOGLE_ABSL_DCHECK(google::protobuf::Arena::is_arena_constructable<T>::value);
GOOGLE_ABSL_DCHECK(google::protobuf::Arena::is_destructor_skippable<T>::value);
}
~ArenaHolder() {

@ -39,9 +39,9 @@
#include <typeinfo>
#include <vector>
#include "google/protobuf/stubs/logging.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/barrier.h"
#include "google/protobuf/arena_test_util.h"
@ -1467,7 +1467,7 @@ TEST(ArenaTest, Alignment) {
Arena arena;
for (int i = 0; i < 200; i++) {
void* p = Arena::CreateArray<char>(&arena, i);
GOOGLE_CHECK_EQ(reinterpret_cast<uintptr_t>(p) % 8, 0) << i << ": " << p;
GOOGLE_ABSL_CHECK_EQ(reinterpret_cast<uintptr_t>(p) % 8, 0) << i << ": " << p;
}
}

@ -202,7 +202,7 @@ std::string* ArenaStringPtr::MutableNoCopy(Arena* arena) {
if (tagged_ptr_.IsMutable()) {
return tagged_ptr_.Get();
} else {
GOOGLE_DCHECK(IsDefault());
GOOGLE_ABSL_DCHECK(IsDefault());
// Allocate empty. The contents are not relevant.
return NewString(arena);
}
@ -211,7 +211,7 @@ std::string* ArenaStringPtr::MutableNoCopy(Arena* arena) {
template <typename... Lazy>
std::string* ArenaStringPtr::MutableSlow(::google::protobuf::Arena* arena,
const Lazy&... lazy_default) {
GOOGLE_DCHECK(IsDefault());
GOOGLE_ABSL_DCHECK(IsDefault());
// For empty defaults, this ends up calling the default constructor which is
// more efficient than a copy construction from
@ -285,7 +285,7 @@ const char* EpsCopyInputStream::ReadArenaString(const char* ptr,
ArenaStringPtr* s,
Arena* arena) {
ScopedCheckPtrInvariants check(&s->tagged_ptr_);
GOOGLE_DCHECK(arena != nullptr);
GOOGLE_ABSL_DCHECK(arena != nullptr);
int size = ReadSize(&ptr);
if (!ptr) return nullptr;

@ -197,11 +197,11 @@ class TaggedStringPtr {
private:
static inline void assert_aligned(const void* p) {
GOOGLE_DCHECK_EQ(reinterpret_cast<uintptr_t>(p) & kMask, 0UL);
GOOGLE_ABSL_DCHECK_EQ(reinterpret_cast<uintptr_t>(p) & kMask, 0UL);
}
inline std::string* TagAs(Type type, std::string* p) {
GOOGLE_DCHECK(p != nullptr);
GOOGLE_ABSL_DCHECK(p != nullptr);
assert_aligned(p);
ptr_ = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(p) | type);
return p;
@ -478,8 +478,8 @@ inline void ArenaStringPtr::ClearNonDefaultToEmpty() {
}
inline std::string* ArenaStringPtr::UnsafeMutablePointer() {
GOOGLE_DCHECK(tagged_ptr_.IsMutable());
GOOGLE_DCHECK(tagged_ptr_.Get() != nullptr);
GOOGLE_ABSL_DCHECK(tagged_ptr_.IsMutable());
GOOGLE_ABSL_DCHECK(tagged_ptr_.Get() != nullptr);
return tagged_ptr_.Get();
}

@ -37,10 +37,10 @@
#include <utility>
#include <vector>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/message_lite.h"
#include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"

@ -445,7 +445,7 @@ class ThreadSafeArenazSamplerTestThread : public Thread {
protobuf_test_messages::proto2::TestAllTypesProto2>
message = google::protobuf::MakeArenaSafeUnique<
protobuf_test_messages::proto2::TestAllTypesProto2>(arena_);
GOOGLE_CHECK(message != nullptr);
GOOGLE_ABSL_CHECK(message != nullptr);
// Signal that a message on the arena has been created. This should create
// a SerialArena for this thread.
if (barrier_->Block()) {
@ -508,7 +508,7 @@ class SampleFirstArenaThread : public Thread {
protobuf_test_messages::proto2::TestAllTypesProto2>
message = google::protobuf::MakeArenaSafeUnique<
protobuf_test_messages::proto2::TestAllTypesProto2>(&arena);
GOOGLE_CHECK(message != nullptr);
GOOGLE_ABSL_CHECK(message != nullptr);
arena_created_.Notify();
samples_counted_.WaitForNotification();
}

@ -48,13 +48,14 @@
#include <vector>
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/base/call_once.h"
#include "absl/base/casts.h"
#include "absl/base/dynamic_annotations.h"
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/hash/hash.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_cat.h"
@ -361,7 +362,7 @@ class FlatAllocatorImpl {
template <typename U>
void PlanArray(int array_size) {
// We can't call PlanArray after FinalizePlanning has been called.
GOOGLE_CHECK(!has_allocated());
GOOGLE_ABSL_CHECK(!has_allocated());
if (std::is_trivially_destructible<U>::value) {
// Trivial types are aligned to 8 bytes.
static_assert(alignof(U) <= 8, "");
@ -382,13 +383,13 @@ class FlatAllocatorImpl {
using TypeToUse = typename std::conditional<trivial, char, U>::type;
// We can only allocate after FinalizePlanning has been called.
GOOGLE_CHECK(has_allocated());
GOOGLE_ABSL_CHECK(has_allocated());
TypeToUse*& data = pointers_.template Get<TypeToUse>();
int& used = used_.template Get<TypeToUse>();
U* res = reinterpret_cast<U*>(data + used);
used += trivial ? RoundUpTo<8>(array_size * sizeof(U)) : array_size;
GOOGLE_CHECK_LE(used, total_.template Get<TypeToUse>());
GOOGLE_ABSL_CHECK_LE(used, total_.template Get<TypeToUse>());
return res;
}
@ -407,7 +408,7 @@ class FlatAllocatorImpl {
// and the other 3 indices are specified in the result.
void PlanFieldNames(const std::string& name,
const std::string* opt_json_name) {
GOOGLE_CHECK(!has_allocated());
GOOGLE_ABSL_CHECK(!has_allocated());
// Fast path for snake_case names, which follow the style guide.
if (opt_json_name == nullptr) {
@ -448,7 +449,7 @@ class FlatAllocatorImpl {
FieldNamesResult AllocateFieldNames(const std::string& name,
const std::string& scope,
const std::string* opt_json_name) {
GOOGLE_CHECK(has_allocated());
GOOGLE_ABSL_CHECK(has_allocated());
std::string full_name =
scope.empty() ? name : absl::StrCat(scope, ".", name);
@ -504,11 +505,11 @@ class FlatAllocatorImpl {
template <typename Alloc>
void FinalizePlanning(Alloc& alloc) {
GOOGLE_CHECK(!has_allocated());
GOOGLE_ABSL_CHECK(!has_allocated());
pointers_ = alloc->CreateFlatAlloc(total_)->Pointers();
GOOGLE_CHECK(has_allocated());
GOOGLE_ABSL_CHECK(has_allocated());
}
void ExpectConsumed() const {
@ -544,7 +545,7 @@ class FlatAllocatorImpl {
template <typename U>
bool ExpectConsumed() const {
GOOGLE_CHECK_EQ(total_.template Get<U>(), used_.template Get<U>());
GOOGLE_ABSL_CHECK_EQ(total_.template Get<U>(), used_.template Get<U>());
return true;
}
@ -693,7 +694,7 @@ class Symbol {
return absl::string_view(sub_package_file_descriptor()->file->package())
.substr(0, sub_package_file_descriptor()->name_size);
default:
GOOGLE_CHECK(false);
GOOGLE_ABSL_CHECK(false);
}
return "";
}
@ -726,7 +727,7 @@ class Symbol {
case METHOD:
return {method_descriptor()->service(), method_descriptor()->name()};
default:
GOOGLE_CHECK(false);
GOOGLE_ABSL_CHECK(false);
}
return {};
}
@ -814,7 +815,7 @@ const char* FileDescriptor::SyntaxName(FileDescriptor::Syntax syntax) {
case SYNTAX_UNKNOWN:
return "unknown";
}
GOOGLE_LOG(FATAL) << "can't reach here.";
GOOGLE_ABSL_LOG(FATAL) << "can't reach here.";
return nullptr;
}
@ -1393,7 +1394,7 @@ DescriptorPool::Tables::Tables() {
});
}
DescriptorPool::Tables::~Tables() { GOOGLE_DCHECK(checkpoints_.empty()); }
DescriptorPool::Tables::~Tables() { GOOGLE_ABSL_DCHECK(checkpoints_.empty()); }
FileDescriptorTables::FileDescriptorTables() {}
@ -1413,7 +1414,7 @@ void DescriptorPool::Tables::AddCheckpoint() {
}
void DescriptorPool::Tables::ClearLastCheckpoint() {
GOOGLE_DCHECK(!checkpoints_.empty());
GOOGLE_ABSL_DCHECK(!checkpoints_.empty());
checkpoints_.pop_back();
if (checkpoints_.empty()) {
// All checkpoints have been cleared: we can now commit all of the pending
@ -1425,7 +1426,7 @@ void DescriptorPool::Tables::ClearLastCheckpoint() {
}
void DescriptorPool::Tables::RollbackToLastCheckpoint() {
GOOGLE_DCHECK(!checkpoints_.empty());
GOOGLE_ABSL_DCHECK(!checkpoints_.empty());
const CheckPoint& checkpoint = checkpoints_.back();
for (size_t i = checkpoint.pending_symbols_before_checkpoint;
@ -1679,7 +1680,7 @@ inline void DescriptorPool::Tables::FindAllExtensions(
bool DescriptorPool::Tables::AddSymbol(const std::string& full_name,
Symbol symbol) {
GOOGLE_DCHECK_EQ(full_name, symbol.full_name());
GOOGLE_ABSL_DCHECK_EQ(full_name, symbol.full_name());
if (symbols_by_name_.insert(symbol).second) {
symbols_after_checkpoint_.push_back(symbol);
return true;
@ -1691,8 +1692,8 @@ bool DescriptorPool::Tables::AddSymbol(const std::string& full_name,
bool FileDescriptorTables::AddAliasUnderParent(const void* parent,
const std::string& name,
Symbol symbol) {
GOOGLE_DCHECK_EQ(name, symbol.parent_name_key().second);
GOOGLE_DCHECK_EQ(parent, symbol.parent_name_key().first);
GOOGLE_ABSL_DCHECK_EQ(name, symbol.parent_name_key().second);
GOOGLE_ABSL_DCHECK_EQ(parent, symbol.parent_name_key().first);
return symbols_by_parent_.insert(symbol).second;
}
@ -1926,7 +1927,7 @@ void DescriptorPool::InternalAddGeneratedFile(
// Therefore, when we parse one, we have to be very careful to avoid using
// any descriptor-based operations, since this might cause infinite recursion
// or deadlock.
GOOGLE_CHECK(GeneratedDatabase()->Add(encoded_file_descriptor, size));
GOOGLE_ABSL_CHECK(GeneratedDatabase()->Add(encoded_file_descriptor, size));
}
@ -2230,13 +2231,13 @@ const EnumValueDescriptor* Descriptor::FindEnumValueByName(
const FieldDescriptor* Descriptor::map_key() const {
if (!options().map_entry()) return nullptr;
GOOGLE_DCHECK_EQ(field_count(), 2);
GOOGLE_ABSL_DCHECK_EQ(field_count(), 2);
return field(0);
}
const FieldDescriptor* Descriptor::map_value() const {
if (!options().map_entry()) return nullptr;
GOOGLE_DCHECK_EQ(field_count(), 2);
GOOGLE_ABSL_DCHECK_EQ(field_count(), 2);
return field(1);
}
@ -2473,7 +2474,7 @@ bool FieldDescriptor::is_map_message_type() const {
std::string FieldDescriptor::DefaultValueAsString(
bool quote_string_type) const {
GOOGLE_CHECK(has_default_value()) << "No default value";
GOOGLE_ABSL_CHECK(has_default_value()) << "No default value";
switch (cpp_type()) {
case CPPTYPE_INT32:
return absl::StrCat(default_value_int32_t());
@ -2502,10 +2503,10 @@ std::string FieldDescriptor::DefaultValueAsString(
case CPPTYPE_ENUM:
return default_value_enum()->name();
case CPPTYPE_MESSAGE:
GOOGLE_LOG(DFATAL) << "Messages can't have default values!";
GOOGLE_ABSL_LOG(DFATAL) << "Messages can't have default values!";
break;
}
GOOGLE_LOG(FATAL) << "Can't get here: failed to get default value as string";
GOOGLE_ABSL_LOG(FATAL) << "Can't get here: failed to get default value as string";
return "";
}
@ -2559,7 +2560,7 @@ void FileDescriptor::CopyHeadingTo(FileDescriptorProto* proto) const {
void FileDescriptor::CopyJsonNameTo(FileDescriptorProto* proto) const {
if (message_type_count() != proto->message_type_size() ||
extension_count() != proto->extension_size()) {
GOOGLE_LOG(ERROR) << "Cannot copy json_name to a proto of a different size.";
GOOGLE_ABSL_LOG(ERROR) << "Cannot copy json_name to a proto of a different size.";
return;
}
for (int i = 0; i < message_type_count(); i++) {
@ -2616,7 +2617,7 @@ void Descriptor::CopyJsonNameTo(DescriptorProto* proto) const {
if (field_count() != proto->field_size() ||
nested_type_count() != proto->nested_type_size() ||
extension_count() != proto->extension_size()) {
GOOGLE_LOG(ERROR) << "Cannot copy json_name to a proto of a different size.";
GOOGLE_ABSL_LOG(ERROR) << "Cannot copy json_name to a proto of a different size.";
return;
}
for (int i = 0; i < field_count(); i++) {
@ -2838,8 +2839,8 @@ bool RetrieveOptions(int depth, const Message& options,
return RetrieveOptionsAssumingRightPool(depth, *dynamic_options,
option_entries);
} else {
GOOGLE_LOG(ERROR) << "Found invalid proto option data for: "
<< options.GetDescriptor()->full_name();
GOOGLE_ABSL_LOG(ERROR) << "Found invalid proto option data for: "
<< options.GetDescriptor()->full_name();
return RetrieveOptionsAssumingRightPool(depth, options, option_entries);
}
}
@ -3461,7 +3462,7 @@ void MethodDescriptor::DebugString(
bool FileDescriptor::GetSourceLocation(const std::vector<int>& path,
SourceLocation* out_location) const {
GOOGLE_CHECK(out_location != nullptr);
GOOGLE_ABSL_CHECK(out_location != nullptr);
if (source_code_info_) {
if (const SourceCodeInfo_Location* loc =
tables_->GetSourceLocation(path, source_code_info_)) {
@ -4108,11 +4109,11 @@ class DescriptorBuilder {
const FileDescriptor* DescriptorPool::BuildFile(
const FileDescriptorProto& proto) {
GOOGLE_CHECK(fallback_database_ == nullptr)
GOOGLE_ABSL_CHECK(fallback_database_ == nullptr)
<< "Cannot call BuildFile on a DescriptorPool that uses a "
"DescriptorDatabase. You must instead find a way to get your file "
"into the underlying database.";
GOOGLE_CHECK(mutex_ == nullptr); // Implied by the above GOOGLE_CHECK.
GOOGLE_ABSL_CHECK(mutex_ == nullptr); // Implied by the above GOOGLE_ABSL_CHECK.
tables_->known_bad_symbols_.clear();
tables_->known_bad_files_.clear();
return DescriptorBuilder::New(this, tables_.get(), nullptr)->BuildFile(proto);
@ -4120,11 +4121,11 @@ const FileDescriptor* DescriptorPool::BuildFile(
const FileDescriptor* DescriptorPool::BuildFileCollectingErrors(
const FileDescriptorProto& proto, ErrorCollector* error_collector) {
GOOGLE_CHECK(fallback_database_ == nullptr)
GOOGLE_ABSL_CHECK(fallback_database_ == nullptr)
<< "Cannot call BuildFile on a DescriptorPool that uses a "
"DescriptorDatabase. You must instead find a way to get your file "
"into the underlying database.";
GOOGLE_CHECK(mutex_ == nullptr); // Implied by the above GOOGLE_CHECK.
GOOGLE_ABSL_CHECK(mutex_ == nullptr); // Implied by the above GOOGLE_ABSL_CHECK.
tables_->known_bad_symbols_.clear();
tables_->known_bad_files_.clear();
return DescriptorBuilder::New(this, tables_.get(), error_collector)
@ -4164,10 +4165,10 @@ PROTOBUF_NOINLINE void DescriptorBuilder::AddError(
const std::string& error) {
if (error_collector_ == nullptr) {
if (!had_errors_) {
GOOGLE_LOG(ERROR) << "Invalid proto descriptor for file \"" << filename_
<< "\":";
GOOGLE_ABSL_LOG(ERROR) << "Invalid proto descriptor for file \"" << filename_
<< "\":";
}
GOOGLE_LOG(ERROR) << " " << element_name << ": " << error;
GOOGLE_ABSL_LOG(ERROR) << " " << element_name << ": " << error;
} else {
error_collector_->AddError(filename_, element_name, &descriptor, location,
error);
@ -4218,7 +4219,7 @@ PROTOBUF_NOINLINE void DescriptorBuilder::AddWarning(
DescriptorPool::ErrorCollector::ErrorLocation location,
const std::string& error) {
if (error_collector_ == nullptr) {
GOOGLE_LOG(WARNING) << filename_ << " " << element_name << ": " << error;
GOOGLE_ABSL_LOG(WARNING) << filename_ << " " << element_name << ": " << error;
} else {
error_collector_->AddWarning(filename_, element_name, &descriptor, location,
error);
@ -4596,10 +4597,10 @@ bool DescriptorBuilder::AddSymbol(const std::string& full_name,
// This is only possible if there was already an error adding something of
// the same name.
if (!had_errors_) {
GOOGLE_LOG(DFATAL) << "\"" << full_name
<< "\" not previously defined in "
"symbols_by_name_, but was defined in "
"symbols_by_parent_; this shouldn't be possible.";
GOOGLE_ABSL_LOG(DFATAL) << "\"" << full_name
<< "\" not previously defined in "
"symbols_by_name_, but was defined in "
"symbols_by_parent_; this shouldn't be possible.";
}
return false;
}
@ -4842,7 +4843,7 @@ PROTOBUF_NOINLINE static bool ExistingFileMatchesProto(
// necessary memory allocations that BuildXXX functions below will do on the
// Tables object.
// They *must* be kept in sync. If we miss some PlanArray call we won't have
// enough memory and will GOOGLE_CHECK-fail.
// enough memory and will GOOGLE_ABSL_CHECK-fail.
static void PlanAllocationSize(
const RepeatedPtrField<EnumValueDescriptorProto>& values,
internal::FlatAllocator& alloc) {
@ -6273,8 +6274,8 @@ void DescriptorBuilder::CrossLinkMessage(Descriptor* message,
// Verify that they are contiguous.
// This is assumed by OneofDescriptor::field(i).
// But only if there are no errors.
GOOGLE_CHECK_EQ(out_oneof_decl.fields_ + out_oneof_decl.field_count_,
message->field(i));
GOOGLE_ABSL_CHECK_EQ(out_oneof_decl.fields_ + out_oneof_decl.field_count_,
message->field(i));
}
++out_oneof_decl.field_count_;
}
@ -7250,7 +7251,7 @@ void DescriptorBuilder::ValidateJSType(FieldDescriptor* field,
DescriptorBuilder::OptionInterpreter::OptionInterpreter(
DescriptorBuilder* builder)
: builder_(builder) {
GOOGLE_CHECK(builder_);
GOOGLE_ABSL_CHECK(builder_);
}
DescriptorBuilder::OptionInterpreter::~OptionInterpreter() {}
@ -7269,7 +7270,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretOptions(
// and clear them, since we're about to interpret them.
const FieldDescriptor* uninterpreted_options_field =
options->GetDescriptor()->FindFieldByName("uninterpreted_option");
GOOGLE_CHECK(uninterpreted_options_field != nullptr)
GOOGLE_ABSL_CHECK(uninterpreted_options_field != nullptr)
<< "No field named \"uninterpreted_option\" in the Options proto.";
options->GetReflection()->ClearField(options, uninterpreted_options_field);
@ -7280,7 +7281,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretOptions(
const FieldDescriptor* original_uninterpreted_options_field =
original_options->GetDescriptor()->FindFieldByName(
"uninterpreted_option");
GOOGLE_CHECK(original_uninterpreted_options_field != nullptr)
GOOGLE_ABSL_CHECK(original_uninterpreted_options_field != nullptr)
<< "No field named \"uninterpreted_option\" in the Options proto.";
const int num_uninterpreted_options =
@ -7373,7 +7374,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
// generated pool's mutex, so we can search it the straightforward way.
options_descriptor = options->GetDescriptor();
}
GOOGLE_CHECK(options_descriptor);
GOOGLE_ABSL_CHECK(options_descriptor);
// We iterate over the name parts to drill into the submessages until we find
// the leaf field for the option. As we drill down we remember the current
@ -7508,7 +7509,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
case FieldDescriptor::TYPE_MESSAGE: {
std::string* outstr =
parent_unknown_fields->AddLengthDelimited((*iter)->number());
GOOGLE_CHECK(unknown_fields->SerializeToString(outstr))
GOOGLE_ABSL_CHECK(unknown_fields->SerializeToString(outstr))
<< "Unexpected failure while serializing option submessage "
<< debug_msg_name << "\".";
break;
@ -7521,8 +7522,8 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(
}
default:
GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: "
<< (*iter)->type();
GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: "
<< (*iter)->type();
return false;
}
unknown_fields.reset(parent_unknown_fields.release());
@ -7640,7 +7641,7 @@ void DescriptorBuilder::OptionInterpreter::AddWithoutInterpreting(
const UninterpretedOption& uninterpreted_option, Message* options) {
const FieldDescriptor* field =
options->GetDescriptor()->FindFieldByName("uninterpreted_option");
GOOGLE_CHECK(field != nullptr);
GOOGLE_ABSL_CHECK(field != nullptr);
options->GetReflection()
->AddMessage(options, field)
@ -7700,7 +7701,7 @@ bool DescriptorBuilder::OptionInterpreter::ExamineIfOptionIsSet(
break;
default:
GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: " << type;
GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: " << type;
return false;
}
}
@ -8023,7 +8024,7 @@ bool DescriptorBuilder::OptionInterpreter::SetAggregateOption(
const Descriptor* type = option_field->message_type();
std::unique_ptr<Message> dynamic(dynamic_factory_.GetPrototype(type)->New());
GOOGLE_CHECK(dynamic.get() != nullptr)
GOOGLE_ABSL_CHECK(dynamic.get() != nullptr)
<< "Could not create an instance of " << option_field->DebugString();
AggregateErrorCollector collector;
@ -8043,7 +8044,7 @@ bool DescriptorBuilder::OptionInterpreter::SetAggregateOption(
if (option_field->type() == FieldDescriptor::TYPE_MESSAGE) {
unknown_fields->AddLengthDelimited(option_field->number(), serial);
} else {
GOOGLE_CHECK_EQ(option_field->type(), FieldDescriptor::TYPE_GROUP);
GOOGLE_ABSL_CHECK_EQ(option_field->type(), FieldDescriptor::TYPE_GROUP);
UnknownFieldSet* group = unknown_fields->AddGroup(option_field->number());
group->ParseFromString(serial);
}
@ -8070,7 +8071,7 @@ void DescriptorBuilder::OptionInterpreter::SetInt32(
break;
default:
GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT32: " << type;
GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT32: " << type;
break;
}
}
@ -8093,7 +8094,7 @@ void DescriptorBuilder::OptionInterpreter::SetInt64(
break;
default:
GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT64: " << type;
GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT64: " << type;
break;
}
}
@ -8111,7 +8112,7 @@ void DescriptorBuilder::OptionInterpreter::SetUInt32(
break;
default:
GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT32: " << type;
GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT32: " << type;
break;
}
}
@ -8129,7 +8130,7 @@ void DescriptorBuilder::OptionInterpreter::SetUInt64(
break;
default:
GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT64: " << type;
GOOGLE_ABSL_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT64: " << type;
break;
}
}
@ -8171,7 +8172,7 @@ Symbol DescriptorPool::CrossLinkOnDemandHelper(absl::string_view name,
// be looked up when the accessor for the type was called. Set type_,
// enum_type_, message_type_, and default_value_enum_ appropriately.
void FieldDescriptor::InternalTypeOnceInit() const {
GOOGLE_CHECK(file()->finished_building_ == true);
GOOGLE_ABSL_CHECK(file()->finished_building_ == true);
const EnumDescriptor* enum_type = nullptr;
const char* lazy_type_name = reinterpret_cast<const char*>(type_once_ + 1);
const char* lazy_default_value_enum_name =
@ -8206,7 +8207,7 @@ void FieldDescriptor::InternalTypeOnceInit() const {
if (!default_value_enum_) {
// We use the first defined value as the default
// if a default is not explicitly defined.
GOOGLE_CHECK(enum_type->value_count());
GOOGLE_ABSL_CHECK(enum_type->value_count());
default_value_enum_ = enum_type->value(0);
}
}
@ -8252,7 +8253,7 @@ const std::string& FieldDescriptor::PrintableNameForExtension() const {
}
void FileDescriptor::InternalDependenciesOnceInit() const {
GOOGLE_CHECK(finished_building_ == true);
GOOGLE_ABSL_CHECK(finished_building_ == true);
const char* names_ptr = reinterpret_cast<const char*>(dependencies_once_ + 1);
for (int i = 0; i < dependency_count(); i++) {
const char* name = names_ptr;
@ -8287,18 +8288,18 @@ const Descriptor* MethodDescriptor::output_type() const {
namespace internal {
void LazyDescriptor::Set(const Descriptor* descriptor) {
GOOGLE_CHECK(!once_);
GOOGLE_ABSL_CHECK(!once_);
descriptor_ = descriptor;
}
void LazyDescriptor::SetLazy(absl::string_view name,
const FileDescriptor* file) {
// verify Init() has been called and Set hasn't been called yet.
GOOGLE_CHECK(!descriptor_);
GOOGLE_CHECK(!once_);
GOOGLE_CHECK(file && file->pool_);
GOOGLE_CHECK(file->pool_->lazily_build_dependencies_);
GOOGLE_CHECK(!file->finished_building_);
GOOGLE_ABSL_CHECK(!descriptor_);
GOOGLE_ABSL_CHECK(!once_);
GOOGLE_ABSL_CHECK(file && file->pool_);
GOOGLE_ABSL_CHECK(file->pool_->lazily_build_dependencies_);
GOOGLE_ABSL_CHECK(!file->finished_building_);
once_ = ::new (file->pool_->tables_->AllocateBytes(static_cast<int>(
sizeof(absl::once_flag) + name.size() + 1))) absl::once_flag{};
char* lazy_name = reinterpret_cast<char*>(once_ + 1);
@ -8310,7 +8311,7 @@ void LazyDescriptor::Once(const ServiceDescriptor* service) {
if (once_) {
absl::call_once(*once_, [&] {
auto* file = service->file();
GOOGLE_CHECK(file->finished_building_);
GOOGLE_ABSL_CHECK(file->finished_building_);
const char* lazy_name = reinterpret_cast<const char*>(once_ + 1);
descriptor_ =
file->pool_->CrossLinkOnDemandHelper(lazy_name, false).descriptor();

@ -64,9 +64,10 @@
#include <vector>
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/port.h"
#include "absl/base/call_once.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/mutex.h"
#include "google/protobuf/port.h"
@ -1799,7 +1800,7 @@ class PROTOBUF_EXPORT DescriptorPool {
// this pool will be slower, since they will have to obtain locks too.
// - An ErrorCollector may optionally be given to collect validation errors
// in files loaded from the database. If not given, errors will be printed
// to GOOGLE_LOG(ERROR). Remember that files are built on-demand, so this
// to GOOGLE_ABSL_LOG(ERROR). Remember that files are built on-demand, so this
// ErrorCollector may be called from any thread that calls one of the
// Find*By*() methods.
// - The DescriptorDatabase must not be mutated during the lifetime of
@ -1926,7 +1927,7 @@ class PROTOBUF_EXPORT DescriptorPool {
// this DescriptorPool. All dependencies of the file must already be in
// the pool. Returns the resulting FileDescriptor, or nullptr if there were
// problems with the input (e.g. the message was invalid, or dependencies
// were missing). Details about the errors are written to GOOGLE_LOG(ERROR).
// were missing). Details about the errors are written to GOOGLE_ABSL_LOG(ERROR).
const FileDescriptor* BuildFile(const FileDescriptorProto& proto);
// Same as BuildFile() except errors are sent to the given ErrorCollector.
@ -2325,12 +2326,12 @@ inline const OneofDescriptor* FieldDescriptor::containing_oneof() const {
}
inline int FieldDescriptor::index_in_oneof() const {
GOOGLE_DCHECK(is_oneof_);
GOOGLE_ABSL_DCHECK(is_oneof_);
return static_cast<int>(this - scope_.containing_oneof->field(0));
}
inline const Descriptor* FieldDescriptor::extension_scope() const {
GOOGLE_CHECK(is_extension_);
GOOGLE_ABSL_CHECK(is_extension_);
return scope_.extension_scope;
}
@ -2514,7 +2515,7 @@ struct FieldRangeImpl {
value_type operator*() { return descriptor->field(idx); }
friend bool operator==(const Iterator& a, const Iterator& b) {
GOOGLE_DCHECK(a.descriptor == b.descriptor);
GOOGLE_ABSL_DCHECK(a.descriptor == b.descriptor);
return a.idx == b.idx;
}
friend bool operator!=(const Iterator& a, const Iterator& b) {

@ -51,7 +51,7 @@ namespace {
void RecordMessageNames(const DescriptorProto& desc_proto,
const std::string& prefix,
std::set<std::string>* output) {
GOOGLE_CHECK(desc_proto.has_name());
GOOGLE_ABSL_CHECK(desc_proto.has_name());
std::string full_name = prefix.empty()
? desc_proto.name()
: absl::StrCat(prefix, ".", desc_proto.name());
@ -81,7 +81,7 @@ bool ForAllFileProtos(DescriptorDatabase* db, Fn callback,
for (const auto& f : file_names) {
file_proto.Clear();
if (!db->FindFileByName(f, &file_proto)) {
GOOGLE_LOG(ERROR) << "File not found in database (unexpected): " << f;
GOOGLE_ABSL_LOG(ERROR) << "File not found in database (unexpected): " << f;
return false;
}
callback(file_proto, &set);
@ -120,7 +120,7 @@ template <typename Value>
bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddFile(
const FileDescriptorProto& file, Value value) {
if (!by_name_.insert({file.name(), value}).second) {
GOOGLE_LOG(ERROR) << "File already exists in database: " << file.name();
GOOGLE_ABSL_LOG(ERROR) << "File already exists in database: " << file.name();
return false;
}
@ -204,7 +204,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
// relies on the fact that '.' sorts before all other characters that are
// valid in symbol names).
if (!ValidateSymbolName(name)) {
GOOGLE_LOG(ERROR) << "Invalid symbol name: " << name;
GOOGLE_ABSL_LOG(ERROR) << "Invalid symbol name: " << name;
return false;
}
@ -220,10 +220,10 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
}
if (IsSubSymbol(iter->first, name)) {
GOOGLE_LOG(ERROR) << "Symbol name \"" << name
<< "\" conflicts with the existing "
"symbol \""
<< iter->first << "\".";
GOOGLE_ABSL_LOG(ERROR) << "Symbol name \"" << name
<< "\" conflicts with the existing "
"symbol \""
<< iter->first << "\".";
return false;
}
@ -235,10 +235,10 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(
++iter;
if (iter != by_symbol_.end() && IsSubSymbol(name, iter->first)) {
GOOGLE_LOG(ERROR) << "Symbol name \"" << name
<< "\" conflicts with the existing "
"symbol \""
<< iter->first << "\".";
GOOGLE_ABSL_LOG(ERROR) << "Symbol name \"" << name
<< "\" conflicts with the existing "
"symbol \""
<< iter->first << "\".";
return false;
}
@ -278,10 +278,11 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddExtension(
{std::make_pair(field.extendee().substr(1), field.number()),
value})
.second) {
GOOGLE_LOG(ERROR) << "Extension conflicts with extension already in database: "
"extend "
<< field.extendee() << " { " << field.name() << " = "
<< field.number() << " } from:" << filename;
GOOGLE_ABSL_LOG(ERROR)
<< "Extension conflicts with extension already in database: "
"extend "
<< field.extendee() << " { " << field.name() << " = "
<< field.number() << " } from:" << filename;
return false;
}
} else {
@ -567,8 +568,8 @@ bool EncodedDescriptorDatabase::Add(const void* encoded_file_descriptor,
if (file.ParseFromArray(encoded_file_descriptor, size)) {
return index_->AddFile(file, std::make_pair(encoded_file_descriptor, size));
} else {
GOOGLE_LOG(ERROR) << "Invalid file descriptor data passed to "
"EncodedDescriptorDatabase::Add().";
GOOGLE_ABSL_LOG(ERROR) << "Invalid file descriptor data passed to "
"EncodedDescriptorDatabase::Add().";
return false;
}
}
@ -639,7 +640,7 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddFile(const FileProto& file,
all_values_.push_back({value.first, value.second, {}});
if (!ValidateSymbolName(file.package())) {
GOOGLE_LOG(ERROR) << "Invalid package name: " << file.package();
GOOGLE_ABSL_LOG(ERROR) << "Invalid package name: " << file.package();
return false;
}
all_values_.back().encoded_package = EncodeString(file.package());
@ -650,7 +651,7 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddFile(const FileProto& file,
.second ||
std::binary_search(by_name_flat_.begin(), by_name_flat_.end(),
file.name(), by_name_.key_comp())) {
GOOGLE_LOG(ERROR) << "File already exists in database: " << file.name();
GOOGLE_ABSL_LOG(ERROR) << "File already exists in database: " << file.name();
return false;
}
@ -677,9 +678,9 @@ static bool CheckForMutualSubsymbols(absl::string_view symbol_name, Iter* iter,
Iter2 end, const Index& index) {
if (*iter != end) {
if (IsSubSymbol((*iter)->AsString(index), symbol_name)) {
GOOGLE_LOG(ERROR) << "Symbol name \"" << symbol_name
<< "\" conflicts with the existing symbol \""
<< (*iter)->AsString(index) << "\".";
GOOGLE_ABSL_LOG(ERROR) << "Symbol name \"" << symbol_name
<< "\" conflicts with the existing symbol \""
<< (*iter)->AsString(index) << "\".";
return false;
}
@ -691,9 +692,9 @@ static bool CheckForMutualSubsymbols(absl::string_view symbol_name, Iter* iter,
++*iter;
if (*iter != end && IsSubSymbol(symbol_name, (*iter)->AsString(index))) {
GOOGLE_LOG(ERROR) << "Symbol name \"" << symbol_name
<< "\" conflicts with the existing symbol \""
<< (*iter)->AsString(index) << "\".";
GOOGLE_ABSL_LOG(ERROR) << "Symbol name \"" << symbol_name
<< "\" conflicts with the existing symbol \""
<< (*iter)->AsString(index) << "\".";
return false;
}
}
@ -712,7 +713,7 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddSymbol(
// relies on the fact that '.' sorts before all other characters that are
// valid in symbol names).
if (!ValidateSymbolName(symbol)) {
GOOGLE_LOG(ERROR) << "Invalid symbol name: " << entry_as_string;
GOOGLE_ABSL_LOG(ERROR) << "Invalid symbol name: " << entry_as_string;
return false;
}
@ -765,10 +766,11 @@ bool EncodedDescriptorDatabase::DescriptorIndex::AddExtension(
by_extension_flat_.begin(), by_extension_flat_.end(),
std::make_pair(field.extendee().substr(1), field.number()),
by_extension_.key_comp())) {
GOOGLE_LOG(ERROR) << "Extension conflicts with extension already in database: "
"extend "
<< field.extendee() << " { " << field.name() << " = "
<< field.number() << " } from:" << filename;
GOOGLE_ABSL_LOG(ERROR)
<< "Extension conflicts with extension already in database: "
"extend "
<< field.extendee() << " { " << field.name() << " = "
<< field.number() << " } from:" << filename;
return false;
}
} else {

@ -171,7 +171,7 @@ class PROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
// Adds the FileDescriptorProto to the database, making a copy. The object
// can be deleted after Add() returns. Returns false if the file conflicted
// with a file already in the database, in which case an error will have
// been written to GOOGLE_LOG(ERROR).
// been written to GOOGLE_ABSL_LOG(ERROR).
bool Add(const FileDescriptorProto& file);
// Adds the FileDescriptorProto to the database and takes ownership of it.

@ -39,7 +39,6 @@
#include <algorithm>
#include <memory>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/text_format.h"

@ -46,7 +46,6 @@
#include "google/protobuf/unittest.pb.h"
#include "google/protobuf/unittest_custom_options.pb.h"
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor_database.h"
@ -55,6 +54,8 @@
#include <gmock/gmock.h>
#include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/unittest_lazy_dependencies.pb.h"
#include "google/protobuf/unittest_lazy_dependencies_custom_option.pb.h"
#include "google/protobuf/unittest_lazy_dependencies_enum.pb.h"
@ -2990,7 +2991,7 @@ class AllowUnknownDependenciesTest
return pool_->FindFileByName(proto.name());
}
}
GOOGLE_LOG(FATAL) << "Can't get here.";
GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return nullptr;
}
@ -3215,7 +3216,7 @@ TEST_P(AllowUnknownDependenciesTest,
const FileDescriptor* file = BuildFile(test_proto);
ASSERT_TRUE(file != nullptr);
GOOGLE_LOG(INFO) << file->DebugString();
GOOGLE_ABSL_LOG(INFO) << file->DebugString();
EXPECT_EQ(0, file->dependency_count());
ASSERT_EQ(1, file->message_type_count());
@ -6067,7 +6068,7 @@ TEST_F(ValidationErrorTest, RollbackAfterError) {
}
TEST_F(ValidationErrorTest, ErrorsReportedToLogError) {
// Test that errors are reported to GOOGLE_LOG(ERROR) if no error collector is
// Test that errors are reported to GOOGLE_ABSL_LOG(ERROR) if no error collector is
// provided.
FileDescriptorProto file_proto;
@ -7402,11 +7403,11 @@ class ExponentialErrorDatabase : public DescriptorDatabase {
absl::string_view end_with, int32_t* file_num) {
if (!absl::ConsumePrefix(&name, begin_with)) return;
if (!absl::ConsumeSuffix(&name, end_with)) return;
GOOGLE_CHECK(absl::SimpleAtoi(name, file_num));
GOOGLE_ABSL_CHECK(absl::SimpleAtoi(name, file_num));
}
bool PopulateFile(int file_num, FileDescriptorProto* output) {
GOOGLE_CHECK_GE(file_num, 0);
GOOGLE_ABSL_CHECK_GE(file_num, 0);
output->Clear();
output->set_name(absl::Substitute("file$0.proto", file_num));
// file0.proto doesn't define Message0
@ -7431,7 +7432,7 @@ TEST_F(DatabaseBackedPoolTest, DoesntReloadKnownBadFiles) {
ExponentialErrorDatabase error_database;
DescriptorPool pool(&error_database);
GOOGLE_LOG(INFO) << "A timeout in this test probably indicates a real bug.";
GOOGLE_ABSL_LOG(INFO) << "A timeout in this test probably indicates a real bug.";
EXPECT_TRUE(pool.FindFileByName("file40.proto") == nullptr);
EXPECT_TRUE(pool.FindMessageTypeByName("Message40") == nullptr);
@ -7476,8 +7477,8 @@ class AbortingErrorCollector : public DescriptorPool::ErrorCollector {
void AddError(const std::string& filename, const std::string& element_name,
const Message* message, ErrorLocation location,
const std::string& error_message) override {
GOOGLE_LOG(FATAL) << "AddError() called unexpectedly: " << filename << " ["
<< element_name << "]: " << error_message;
GOOGLE_ABSL_LOG(FATAL) << "AddError() called unexpectedly: " << filename << " ["
<< element_name << "]: " << error_message;
}
};

@ -178,7 +178,7 @@ int FieldSpaceUsed(const FieldDescriptor* field) {
}
}
GOOGLE_LOG(DFATAL) << "Can't get here.";
GOOGLE_ABSL_LOG(DFATAL) << "Can't get here.";
return 0;
}
@ -587,7 +587,7 @@ DynamicMessage::~DynamicMessage() {
void DynamicMessage::CrossLinkPrototypes() {
// This should only be called on the prototype message.
GOOGLE_CHECK(is_prototype());
GOOGLE_ABSL_CHECK(is_prototype());
DynamicMessageFactory* factory = type_info_->factory;
const Descriptor* descriptor = type_info_->type;

@ -163,9 +163,9 @@ class PROTOBUF_EXPORT DynamicMapSorter {
#ifndef NDEBUG
for (size_t j = 1; j < static_cast<size_t>(map_size); j++) {
if (!comparator(result[j - 1], result[j])) {
GOOGLE_LOG(ERROR) << (comparator(result[j], result[j - 1])
? "internal error in map key sorting"
: "map keys are not unique");
GOOGLE_ABSL_LOG(ERROR) << (comparator(result[j], result[j - 1])
? "internal error in map key sorting"
: "map keys are not unique");
}
}
#endif
@ -212,7 +212,7 @@ class PROTOBUF_EXPORT DynamicMapSorter {
return first < second;
}
default:
GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
GOOGLE_ABSL_LOG(DFATAL) << "Invalid key for map field.";
return true;
}
}

@ -44,7 +44,6 @@
#include <memory>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/testing/googletest.h"

@ -33,10 +33,9 @@
#include <stdint.h>
#include <string>
#include <utility>
#include "google/protobuf/stubs/logging.h"
// clang-format off
#include "google/protobuf/port_def.inc"
// clang-format on

@ -59,7 +59,7 @@ namespace internal {
namespace {
inline WireFormatLite::FieldType real_type(FieldType type) {
GOOGLE_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE);
GOOGLE_ABSL_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE);
return static_cast<WireFormatLite::FieldType>(type);
}
@ -92,9 +92,9 @@ void Register(const ExtensionInfo& info) {
static auto local_static_registry = OnShutdownDelete(new ExtensionRegistry);
global_registry = local_static_registry;
if (!local_static_registry->insert(info).second) {
GOOGLE_LOG(FATAL) << "Multiple extension registrations for type \""
<< info.message->GetTypeName() << "\", field number "
<< info.number << ".";
GOOGLE_ABSL_LOG(FATAL) << "Multiple extension registrations for type \""
<< info.message->GetTypeName() << "\", field number "
<< info.number << ".";
}
}
@ -130,9 +130,9 @@ void ExtensionSet::RegisterExtension(const MessageLite* extendee, int number,
FieldType type, bool is_repeated,
bool is_packed,
LazyEagerVerifyFnType verify_func) {
GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_ENUM);
GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_MESSAGE);
GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_GROUP);
GOOGLE_ABSL_CHECK_NE(type, WireFormatLite::TYPE_ENUM);
GOOGLE_ABSL_CHECK_NE(type, WireFormatLite::TYPE_MESSAGE);
GOOGLE_ABSL_CHECK_NE(type, WireFormatLite::TYPE_GROUP);
ExtensionInfo info(extendee, number, type, is_repeated, is_packed,
verify_func);
Register(info);
@ -155,7 +155,7 @@ void ExtensionSet::RegisterEnumExtension(const MessageLite* extendee,
int number, FieldType type,
bool is_repeated, bool is_packed,
EnumValidityFunc* is_valid) {
GOOGLE_CHECK_EQ(type, WireFormatLite::TYPE_ENUM);
GOOGLE_ABSL_CHECK_EQ(type, WireFormatLite::TYPE_ENUM);
ExtensionInfo info(extendee, number, type, is_repeated, is_packed, nullptr);
info.enum_validity_check.func = CallNoArgValidityFunc;
// See comment in CallNoArgValidityFunc() about why we use a c-style cast.
@ -168,8 +168,8 @@ void ExtensionSet::RegisterMessageExtension(const MessageLite* extendee,
bool is_repeated, bool is_packed,
const MessageLite* prototype,
LazyEagerVerifyFnType verify_func) {
GOOGLE_CHECK(type == WireFormatLite::TYPE_MESSAGE ||
type == WireFormatLite::TYPE_GROUP);
GOOGLE_ABSL_CHECK(type == WireFormatLite::TYPE_MESSAGE ||
type == WireFormatLite::TYPE_GROUP);
ExtensionInfo info(extendee, number, type, is_repeated, is_packed,
verify_func);
info.message_info = {prototype};
@ -219,7 +219,7 @@ void ExtensionSet::DeleteFlatMap(const ExtensionSet::KeyValue* flat,
bool ExtensionSet::Has(int number) const {
const Extension* ext = FindOrNull(number);
if (ext == nullptr) return false;
GOOGLE_DCHECK(!ext->is_repeated);
GOOGLE_ABSL_DCHECK(!ext->is_repeated);
return !ext->is_cleared;
}
@ -245,11 +245,13 @@ int ExtensionSet::ExtensionSize(int number) const {
FieldType ExtensionSet::ExtensionType(int number) const {
const Extension* ext = FindOrNull(number);
if (ext == nullptr) {
GOOGLE_LOG(DFATAL) << "Don't lookup extension types if they aren't present (1). ";
GOOGLE_ABSL_LOG(DFATAL)
<< "Don't lookup extension types if they aren't present (1). ";
return 0;
}
if (ext->is_cleared) {
GOOGLE_LOG(DFATAL) << "Don't lookup extension types if they aren't present (2). ";
GOOGLE_ABSL_LOG(DFATAL)
<< "Don't lookup extension types if they aren't present (2). ";
}
return ext->type;
}
@ -269,9 +271,10 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
} // namespace
#define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \
GOOGLE_DCHECK_EQ((EXTENSION).is_repeated ? REPEATED_FIELD : OPTIONAL_FIELD, LABEL); \
GOOGLE_DCHECK_EQ(cpp_type((EXTENSION).type), WireFormatLite::CPPTYPE_##CPPTYPE)
#define GOOGLE_ABSL_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \
GOOGLE_ABSL_DCHECK_EQ((EXTENSION).is_repeated ? REPEATED_FIELD : OPTIONAL_FIELD, \
LABEL); \
GOOGLE_ABSL_DCHECK_EQ(cpp_type((EXTENSION).type), WireFormatLite::CPPTYPE_##CPPTYPE)
// -------------------------------------------------------------------
// Primitives
@ -284,7 +287,7 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
if (extension == nullptr || extension->is_cleared) { \
return default_value; \
} else { \
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
return extension->LOWERCASE##_value; \
} \
} \
@ -295,7 +298,7 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
if (extension == nullptr || extension->is_cleared) { \
return default_value; \
} else { \
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
return extension->LOWERCASE##_value; \
} \
} \
@ -306,11 +309,11 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
Extension* extension; \
if (MaybeNewExtension(number, descriptor, &extension)) { \
extension->type = type; \
GOOGLE_DCHECK_EQ(cpp_type(extension->type), \
WireFormatLite::CPPTYPE_##UPPERCASE); \
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), \
WireFormatLite::CPPTYPE_##UPPERCASE); \
extension->is_repeated = false; \
} else { \
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
} \
extension->is_cleared = false; \
extension->LOWERCASE##_value = value; \
@ -319,24 +322,27 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
LOWERCASE ExtensionSet::GetRepeated##CAMELCASE(int number, int index) \
const { \
const Extension* extension = FindOrNull(number); \
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; \
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
GOOGLE_ABSL_CHECK(extension != nullptr) \
<< "Index out-of-bounds (field is empty)."; \
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
return extension->repeated_##LOWERCASE##_value->Get(index); \
} \
\
const LOWERCASE& ExtensionSet::GetRefRepeated##CAMELCASE(int number, \
int index) const { \
const Extension* extension = FindOrNull(number); \
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; \
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
GOOGLE_ABSL_CHECK(extension != nullptr) \
<< "Index out-of-bounds (field is empty)."; \
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
return extension->repeated_##LOWERCASE##_value->Get(index); \
} \
\
void ExtensionSet::SetRepeated##CAMELCASE(int number, int index, \
LOWERCASE value) { \
Extension* extension = FindOrNull(number); \
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; \
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
GOOGLE_ABSL_CHECK(extension != nullptr) \
<< "Index out-of-bounds (field is empty)."; \
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
extension->repeated_##LOWERCASE##_value->Set(index, value); \
} \
\
@ -346,15 +352,15 @@ enum { REPEATED_FIELD, OPTIONAL_FIELD };
Extension* extension; \
if (MaybeNewExtension(number, descriptor, &extension)) { \
extension->type = type; \
GOOGLE_DCHECK_EQ(cpp_type(extension->type), \
WireFormatLite::CPPTYPE_##UPPERCASE); \
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), \
WireFormatLite::CPPTYPE_##UPPERCASE); \
extension->is_repeated = true; \
extension->is_packed = packed; \
extension->repeated_##LOWERCASE##_value = \
Arena::CreateMessage<RepeatedField<LOWERCASE>>(arena_); \
} else { \
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
GOOGLE_DCHECK_EQ(extension->is_packed, packed); \
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
GOOGLE_ABSL_DCHECK_EQ(extension->is_packed, packed); \
} \
extension->repeated_##LOWERCASE##_value->Add(value); \
}
@ -443,10 +449,10 @@ void* ExtensionSet::MutableRawRepeatedField(int number, FieldType field_type,
}
// Compatible version using old call signature. Does not create extensions when
// the don't already exist; instead, just GOOGLE_CHECK-fails.
// the don't already exist; instead, just GOOGLE_ABSL_CHECK-fails.
void* ExtensionSet::MutableRawRepeatedField(int number) {
Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Extension not found.";
GOOGLE_ABSL_CHECK(extension != nullptr) << "Extension not found.";
// We assume that all the RepeatedField<>* pointers have the same
// size and alignment within the anonymous union in Extension.
return extension->repeated_int32_t_value;
@ -461,7 +467,7 @@ int ExtensionSet::GetEnum(int number, int default_value) const {
// Not present. Return the default value.
return default_value;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
return extension->enum_value;
}
}
@ -473,7 +479,7 @@ const int& ExtensionSet::GetRefEnum(int number,
// Not present. Return the default value.
return default_value;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
return extension->enum_value;
}
}
@ -483,10 +489,10 @@ void ExtensionSet::SetEnum(int number, FieldType type, int value,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM);
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM);
extension->is_repeated = false;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
}
extension->is_cleared = false;
extension->enum_value = value;
@ -494,22 +500,22 @@ void ExtensionSet::SetEnum(int number, FieldType type, int value,
int ExtensionSet::GetRepeatedEnum(int number, int index) const {
const Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
return extension->repeated_enum_value->Get(index);
}
const int& ExtensionSet::GetRefRepeatedEnum(int number, int index) const {
const Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
return extension->repeated_enum_value->Get(index);
}
void ExtensionSet::SetRepeatedEnum(int number, int index, int value) {
Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
extension->repeated_enum_value->Set(index, value);
}
@ -518,14 +524,14 @@ void ExtensionSet::AddEnum(int number, FieldType type, bool packed, int value,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM);
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM);
extension->is_repeated = true;
extension->is_packed = packed;
extension->repeated_enum_value =
Arena::CreateMessage<RepeatedField<int>>(arena_);
} else {
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
GOOGLE_DCHECK_EQ(extension->is_packed, packed);
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
GOOGLE_ABSL_DCHECK_EQ(extension->is_packed, packed);
}
extension->repeated_enum_value->Add(value);
}
@ -540,7 +546,7 @@ const std::string& ExtensionSet::GetString(
// Not present. Return the default value.
return default_value;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING);
return *extension->string_value;
}
}
@ -550,11 +556,11 @@ std::string* ExtensionSet::MutableString(int number, FieldType type,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING);
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING);
extension->is_repeated = false;
extension->string_value = Arena::Create<std::string>(arena_);
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING);
}
extension->is_cleared = false;
return extension->string_value;
@ -563,15 +569,15 @@ std::string* ExtensionSet::MutableString(int number, FieldType type,
const std::string& ExtensionSet::GetRepeatedString(int number,
int index) const {
const Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
return extension->repeated_string_value->Get(index);
}
std::string* ExtensionSet::MutableRepeatedString(int number, int index) {
Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
return extension->repeated_string_value->Mutable(index);
}
@ -580,13 +586,13 @@ std::string* ExtensionSet::AddString(int number, FieldType type,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING);
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING);
extension->is_repeated = true;
extension->is_packed = false;
extension->repeated_string_value =
Arena::CreateMessage<RepeatedPtrField<std::string>>(arena_);
} else {
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
}
return extension->repeated_string_value->Add();
}
@ -601,7 +607,7 @@ const MessageLite& ExtensionSet::GetMessage(
// Not present. Return the default value.
return default_value;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
if (extension->is_lazy) {
return extension->lazymessage_value->GetMessage(default_value, arena_);
} else {
@ -621,14 +627,14 @@ MessageLite* ExtensionSet::MutableMessage(int number, FieldType type,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
extension->is_repeated = false;
extension->is_lazy = false;
extension->message_value = prototype.New(arena_);
extension->is_cleared = false;
return extension->message_value;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
extension->is_cleared = false;
if (extension->is_lazy) {
return extension->lazymessage_value->MutableMessage(prototype, arena_);
@ -650,13 +656,13 @@ void ExtensionSet::SetAllocatedMessage(int number, FieldType type,
ClearExtension(number);
return;
}
GOOGLE_DCHECK(message->GetOwningArena() == nullptr ||
message->GetOwningArena() == arena_);
GOOGLE_ABSL_DCHECK(message->GetOwningArena() == nullptr ||
message->GetOwningArena() == arena_);
Arena* message_arena = message->GetOwningArena();
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
extension->is_repeated = false;
extension->is_lazy = false;
if (message_arena == arena_) {
@ -669,7 +675,7 @@ void ExtensionSet::SetAllocatedMessage(int number, FieldType type,
extension->message_value->CheckTypeAndMergeFrom(*message);
}
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
if (extension->is_lazy) {
extension->lazymessage_value->SetAllocatedMessage(message, arena_);
} else {
@ -700,12 +706,12 @@ void ExtensionSet::UnsafeArenaSetAllocatedMessage(
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
extension->is_repeated = false;
extension->is_lazy = false;
extension->message_value = message;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
if (extension->is_lazy) {
extension->lazymessage_value->UnsafeArenaSetAllocatedMessage(message,
arena_);
@ -726,7 +732,7 @@ MessageLite* ExtensionSet::ReleaseMessage(int number,
// Not present. Return nullptr.
return nullptr;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
MessageLite* ret = nullptr;
if (extension->is_lazy) {
ret = extension->lazymessage_value->ReleaseMessage(prototype, arena_);
@ -755,7 +761,7 @@ MessageLite* ExtensionSet::UnsafeArenaReleaseMessage(
// Not present. Return nullptr.
return nullptr;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
MessageLite* ret = nullptr;
if (extension->is_lazy) {
ret = extension->lazymessage_value->UnsafeArenaReleaseMessage(prototype,
@ -778,15 +784,15 @@ MessageLite* ExtensionSet::UnsafeArenaReleaseMessage(
const MessageLite& ExtensionSet::GetRepeatedMessage(int number,
int index) const {
const Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
return extension->repeated_message_value->Get(index);
}
MessageLite* ExtensionSet::MutableRepeatedMessage(int number, int index) {
Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
return extension->repeated_message_value->Mutable(index);
}
@ -796,12 +802,12 @@ MessageLite* ExtensionSet::AddMessage(int number, FieldType type,
Extension* extension;
if (MaybeNewExtension(number, descriptor, &extension)) {
extension->type = type;
GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);
extension->is_repeated = true;
extension->repeated_message_value =
Arena::CreateMessage<RepeatedPtrField<MessageLite>>(arena_);
} else {
GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
}
// RepeatedPtrField<MessageLite> does not know how to Add() since it cannot
@ -821,12 +827,12 @@ MessageLite* ExtensionSet::AddMessage(int number, FieldType type,
// const Descriptor* message_type,
// MessageFactory* factory)
#undef GOOGLE_DCHECK_TYPE
#undef GOOGLE_ABSL_DCHECK_TYPE
void ExtensionSet::RemoveLast(int number) {
Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_DCHECK(extension->is_repeated);
GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_ABSL_DCHECK(extension->is_repeated);
switch (cpp_type(extension->type)) {
case WireFormatLite::CPPTYPE_INT32:
@ -864,24 +870,24 @@ void ExtensionSet::RemoveLast(int number) {
MessageLite* ExtensionSet::ReleaseLast(int number) {
Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_DCHECK(extension->is_repeated);
GOOGLE_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE);
GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_ABSL_DCHECK(extension->is_repeated);
GOOGLE_ABSL_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE);
return extension->repeated_message_value->ReleaseLast();
}
MessageLite* ExtensionSet::UnsafeArenaReleaseLast(int number) {
Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_DCHECK(extension->is_repeated);
GOOGLE_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE);
GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_ABSL_DCHECK(extension->is_repeated);
GOOGLE_ABSL_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE);
return extension->repeated_message_value->UnsafeArenaReleaseLast();
}
void ExtensionSet::SwapElements(int number, int index1, int index2) {
Extension* extension = FindOrNull(number);
GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_DCHECK(extension->is_repeated);
GOOGLE_ABSL_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
GOOGLE_ABSL_DCHECK(extension->is_repeated);
switch (cpp_type(extension->type)) {
case WireFormatLite::CPPTYPE_INT32:
@ -988,9 +994,9 @@ void ExtensionSet::InternalExtensionMergeFrom(const MessageLite* extendee,
extension->is_packed = other_extension.is_packed;
extension->is_repeated = true;
} else {
GOOGLE_DCHECK_EQ(extension->type, other_extension.type);
GOOGLE_DCHECK_EQ(extension->is_packed, other_extension.is_packed);
GOOGLE_DCHECK(extension->is_repeated);
GOOGLE_ABSL_DCHECK_EQ(extension->type, other_extension.type);
GOOGLE_ABSL_DCHECK_EQ(extension->is_packed, other_extension.is_packed);
GOOGLE_ABSL_DCHECK(extension->is_repeated);
}
switch (cpp_type(other_extension.type)) {
@ -1084,9 +1090,9 @@ void ExtensionSet::InternalExtensionMergeFrom(const MessageLite* extendee,
*other_extension.message_value);
}
} else {
GOOGLE_DCHECK_EQ(extension->type, other_extension.type);
GOOGLE_DCHECK_EQ(extension->is_packed, other_extension.is_packed);
GOOGLE_DCHECK(!extension->is_repeated);
GOOGLE_ABSL_DCHECK_EQ(extension->type, other_extension.type);
GOOGLE_ABSL_DCHECK_EQ(extension->is_packed, other_extension.is_packed);
GOOGLE_ABSL_DCHECK(!extension->is_repeated);
if (other_extension.is_lazy) {
if (extension->is_lazy) {
extension->lazymessage_value->MergeFrom(
@ -1194,7 +1200,7 @@ void ExtensionSet::UnsafeShallowSwapExtension(ExtensionSet* other, int number) {
if (this_ext == other_ext) return;
GOOGLE_DCHECK_EQ(GetArena(), other->GetArena());
GOOGLE_ABSL_DCHECK_EQ(GetArena(), other->GetArena());
if (this_ext != nullptr && other_ext != nullptr) {
std::swap(*this_ext, *other_ext);
@ -1390,7 +1396,7 @@ size_t ExtensionSet::Extension::ByteSize(int number) const {
case WireFormatLite::TYPE_BYTES:
case WireFormatLite::TYPE_GROUP:
case WireFormatLite::TYPE_MESSAGE:
GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
GOOGLE_ABSL_LOG(FATAL) << "Non-primitive types can't be packed.";
break;
}
@ -1491,7 +1497,7 @@ size_t ExtensionSet::Extension::ByteSize(int number) const {
}
int ExtensionSet::Extension::GetSize() const {
GOOGLE_DCHECK(is_repeated);
GOOGLE_ABSL_DCHECK(is_repeated);
switch (cpp_type(type)) {
#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
case WireFormatLite::CPPTYPE_##UPPERCASE: \
@ -1510,7 +1516,7 @@ int ExtensionSet::Extension::GetSize() const {
#undef HANDLE_TYPE
}
GOOGLE_LOG(FATAL) << "Can't get here.";
GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return 0;
}
@ -1659,7 +1665,7 @@ void ExtensionSet::GrowCapacity(size_t minimum_new_capacity) {
hint = new_map.large->insert(hint, {it->first, it->second});
}
flat_size_ = static_cast<uint16_t>(-1);
GOOGLE_DCHECK(is_large());
GOOGLE_ABSL_DCHECK(is_large());
} else {
new_map.flat = Arena::CreateArray<KeyValue>(arena_, new_flat_capacity);
std::copy(begin, end, new_map.flat);
@ -1749,7 +1755,7 @@ uint8_t* ExtensionSet::Extension::InternalSerializeFieldWithCachedSizesToArray(
case WireFormatLite::TYPE_BYTES:
case WireFormatLite::TYPE_GROUP:
case WireFormatLite::TYPE_MESSAGE:
GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
GOOGLE_ABSL_LOG(FATAL) << "Non-primitive types can't be packed.";
break;
}
} else {
@ -1877,7 +1883,7 @@ ExtensionSet::Extension::InternalSerializeMessageSetItemWithCachedSizesToArray(
uint8_t* target, io::EpsCopyOutputStream* stream) const {
if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) {
// Not a valid MessageSet extension, but serialize it the normal way.
GOOGLE_LOG(WARNING) << "Invalid message set extension.";
GOOGLE_ABSL_LOG(WARNING) << "Invalid message set extension.";
return InternalSerializeFieldWithCachedSizesToArray(extendee, extension_set,
number, target, stream);
}

@ -321,7 +321,7 @@ class PROTOBUF_EXPORT ExtensionSet {
// This is an overload of MutableRawRepeatedField to maintain compatibility
// with old code using a previous API. This version of
// MutableRawRepeatedField() will GOOGLE_CHECK-fail on a missing extension.
// MutableRawRepeatedField() will GOOGLE_ABSL_CHECK-fail on a missing extension.
// (E.g.: borg/clients/internal/proto1/proto2_reflection.cc.)
void* MutableRawRepeatedField(int number);
@ -790,8 +790,8 @@ class PROTOBUF_EXPORT ExtensionSet {
return false;
}
GOOGLE_DCHECK(extension->type > 0 &&
extension->type <= WireFormatLite::MAX_FIELD_TYPE);
GOOGLE_ABSL_DCHECK(extension->type > 0 &&
extension->type <= WireFormatLite::MAX_FIELD_TYPE);
auto real_type = static_cast<WireFormatLite::FieldType>(extension->type);
WireFormatLite::WireType expected_wire_type =
@ -1257,7 +1257,7 @@ class EnumTypeTraits {
}
static inline void Set(int number, FieldType field_type, ConstType value,
ExtensionSet* set) {
GOOGLE_DCHECK(IsValid(value));
GOOGLE_ABSL_DCHECK(IsValid(value));
set->SetEnum(number, field_type, value, nullptr);
}
template <typename ExtendeeT>
@ -1289,12 +1289,12 @@ class RepeatedEnumTypeTraits {
}
static inline void Set(int number, int index, ConstType value,
ExtensionSet* set) {
GOOGLE_DCHECK(IsValid(value));
GOOGLE_ABSL_DCHECK(IsValid(value));
set->SetRepeatedEnum(number, index, value);
}
static inline void Add(int number, FieldType field_type, bool is_packed,
ConstType value, ExtensionSet* set) {
GOOGLE_DCHECK(IsValid(value));
GOOGLE_ABSL_DCHECK(IsValid(value));
set->AddEnum(number, field_type, is_packed, value, nullptr);
}
static inline const RepeatedField<Type>& GetRepeated(

@ -104,7 +104,7 @@ void ExtensionSet::AppendToList(
}
inline FieldDescriptor::Type real_type(FieldType type) {
GOOGLE_DCHECK(type > 0 && type <= FieldDescriptor::MAX_TYPE);
GOOGLE_ABSL_DCHECK(type > 0 && type <= FieldDescriptor::MAX_TYPE);
return static_cast<FieldDescriptor::Type>(type);
}
@ -114,15 +114,15 @@ inline FieldDescriptor::CppType cpp_type(FieldType type) {
}
inline WireFormatLite::FieldType field_type(FieldType type) {
GOOGLE_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE);
GOOGLE_ABSL_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE);
return static_cast<WireFormatLite::FieldType>(type);
}
#define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \
GOOGLE_DCHECK_EQ((EXTENSION).is_repeated ? FieldDescriptor::LABEL_REPEATED \
: FieldDescriptor::LABEL_OPTIONAL, \
FieldDescriptor::LABEL_##LABEL); \
GOOGLE_DCHECK_EQ(cpp_type((EXTENSION).type), FieldDescriptor::CPPTYPE_##CPPTYPE)
#define GOOGLE_ABSL_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \
GOOGLE_ABSL_DCHECK_EQ((EXTENSION).is_repeated ? FieldDescriptor::LABEL_REPEATED \
: FieldDescriptor::LABEL_OPTIONAL, \
FieldDescriptor::LABEL_##LABEL); \
GOOGLE_ABSL_DCHECK_EQ(cpp_type((EXTENSION).type), FieldDescriptor::CPPTYPE_##CPPTYPE)
const MessageLite& ExtensionSet::GetMessage(int number,
const Descriptor* message_type,
@ -132,7 +132,7 @@ const MessageLite& ExtensionSet::GetMessage(int number,
// Not present. Return the default value.
return *factory->GetPrototype(message_type);
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
if (extension->is_lazy) {
return extension->lazymessage_value->GetMessage(
*factory->GetPrototype(message_type), arena_);
@ -147,7 +147,7 @@ MessageLite* ExtensionSet::MutableMessage(const FieldDescriptor* descriptor,
Extension* extension;
if (MaybeNewExtension(descriptor->number(), descriptor, &extension)) {
extension->type = descriptor->type();
GOOGLE_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE);
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE);
extension->is_repeated = false;
extension->is_packed = false;
const MessageLite* prototype =
@ -157,7 +157,7 @@ MessageLite* ExtensionSet::MutableMessage(const FieldDescriptor* descriptor,
extension->is_cleared = false;
return extension->message_value;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
extension->is_cleared = false;
if (extension->is_lazy) {
return extension->lazymessage_value->MutableMessage(
@ -175,7 +175,7 @@ MessageLite* ExtensionSet::ReleaseMessage(const FieldDescriptor* descriptor,
// Not present. Return nullptr.
return nullptr;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
MessageLite* ret = nullptr;
if (extension->is_lazy) {
ret = extension->lazymessage_value->ReleaseMessage(
@ -203,7 +203,7 @@ MessageLite* ExtensionSet::UnsafeArenaReleaseMessage(
// Not present. Return nullptr.
return nullptr;
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);
MessageLite* ret = nullptr;
if (extension->is_lazy) {
ret = extension->lazymessage_value->UnsafeArenaReleaseMessage(
@ -224,12 +224,12 @@ ExtensionSet::Extension* ExtensionSet::MaybeNewRepeatedExtension(
Extension* extension;
if (MaybeNewExtension(descriptor->number(), descriptor, &extension)) {
extension->type = descriptor->type();
GOOGLE_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE);
GOOGLE_ABSL_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE);
extension->is_repeated = true;
extension->repeated_message_value =
Arena::CreateMessage<RepeatedPtrField<MessageLite> >(arena_);
} else {
GOOGLE_DCHECK_TYPE(*extension, REPEATED, MESSAGE);
GOOGLE_ABSL_DCHECK_TYPE(*extension, REPEATED, MESSAGE);
}
return extension;
}
@ -248,7 +248,7 @@ MessageLite* ExtensionSet::AddMessage(const FieldDescriptor* descriptor,
const MessageLite* prototype;
if (extension->repeated_message_value->empty()) {
prototype = factory->GetPrototype(descriptor->message_type());
GOOGLE_CHECK(prototype != nullptr);
GOOGLE_ABSL_CHECK(prototype != nullptr);
} else {
prototype = &extension->repeated_message_value->Get(0);
}
@ -290,7 +290,7 @@ bool DescriptorPoolExtensionFinder::Find(int number, ExtensionInfo* output) {
if (extension->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
output->message_info.prototype =
factory_->GetPrototype(extension->message_type());
GOOGLE_CHECK(output->message_info.prototype != nullptr)
GOOGLE_ABSL_CHECK(output->message_info.prototype != nullptr)
<< "Extension factory's GetPrototype() returned nullptr; extension: "
<< extension->full_name();
} else if (extension->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {

@ -76,7 +76,7 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo(
case WireFormatLite::TYPE_BYTES:
case WireFormatLite::TYPE_GROUP:
case WireFormatLite::TYPE_MESSAGE:
GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
GOOGLE_ABSL_LOG(FATAL) << "Non-primitive types can't be packed.";
break;
}
} else {

@ -34,7 +34,6 @@
#include "google/protobuf/extension_set.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/descriptor.h"

@ -101,7 +101,7 @@ failure:
void ZeroFieldsBase::MergeImpl(Message& to_param, const Message& from_param) {
auto* to = static_cast<ZeroFieldsBase*>(&to_param);
const auto* from = static_cast<const ZeroFieldsBase*>(&from_param);
GOOGLE_DCHECK_NE(from, to);
GOOGLE_ABSL_DCHECK_NE(from, to);
to->_internal_metadata_.MergeFrom<UnknownFieldSet>(from->_internal_metadata_);
}

@ -41,9 +41,10 @@
#include <set>
#include <string>
#include "google/protobuf/stubs/logging.h"
#include "absl/base/casts.h"
#include "absl/container/flat_hash_map.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/mutex.h"
@ -177,18 +178,18 @@ using internal::GetPointerAtOffset;
void ReportReflectionUsageError(const Descriptor* descriptor,
const FieldDescriptor* field,
const char* method, const char* description) {
GOOGLE_LOG(FATAL) << "Protocol Buffer reflection usage error:\n"
" Method : google::protobuf::Reflection::"
<< method
<< "\n"
" Message type: "
<< descriptor->full_name()
<< "\n"
" Field : "
<< field->full_name()
<< "\n"
" Problem : "
<< description;
GOOGLE_ABSL_LOG(FATAL) << "Protocol Buffer reflection usage error:\n"
" Method : google::protobuf::Reflection::"
<< method
<< "\n"
" Message type: "
<< descriptor->full_name()
<< "\n"
" Field : "
<< field->full_name()
<< "\n"
" Problem : "
<< description;
}
const char* cpptype_names_[FieldDescriptor::MAX_CPPTYPE + 1] = {
@ -199,7 +200,7 @@ const char* cpptype_names_[FieldDescriptor::MAX_CPPTYPE + 1] = {
static void ReportReflectionUsageTypeError(
const Descriptor* descriptor, const FieldDescriptor* field,
const char* method, FieldDescriptor::CppType expected_type) {
GOOGLE_LOG(FATAL)
GOOGLE_ABSL_LOG(FATAL)
<< "Protocol Buffer reflection usage error:\n"
" Method : google::protobuf::Reflection::"
<< method
@ -221,27 +222,27 @@ static void ReportReflectionUsageTypeError(
static void ReportReflectionUsageEnumTypeError(
const Descriptor* descriptor, const FieldDescriptor* field,
const char* method, const EnumValueDescriptor* value) {
GOOGLE_LOG(FATAL) << "Protocol Buffer reflection usage error:\n"
" Method : google::protobuf::Reflection::"
<< method
<< "\n"
" Message type: "
<< descriptor->full_name()
<< "\n"
" Field : "
<< field->full_name()
<< "\n"
" Problem : Enum value did not match field type:\n"
" Expected : "
<< field->enum_type()->full_name()
<< "\n"
" Actual : "
<< value->full_name();
GOOGLE_ABSL_LOG(FATAL) << "Protocol Buffer reflection usage error:\n"
" Method : google::protobuf::Reflection::"
<< method
<< "\n"
" Message type: "
<< descriptor->full_name()
<< "\n"
" Field : "
<< field->full_name()
<< "\n"
" Problem : Enum value did not match field type:\n"
" Expected : "
<< field->enum_type()->full_name()
<< "\n"
" Actual : "
<< value->full_name();
}
inline void CheckInvalidAccess(const internal::ReflectionSchema& schema,
const FieldDescriptor* field) {
GOOGLE_CHECK(!schema.IsFieldStripped(field))
GOOGLE_ABSL_CHECK(!schema.IsFieldStripped(field))
<< "invalid access to a stripped field " << field->full_name();
}
@ -514,7 +515,7 @@ struct OneofFieldMover {
}
break;
default:
GOOGLE_LOG(FATAL) << "unimplemented type: " << field->cpp_type();
GOOGLE_ABSL_LOG(FATAL) << "unimplemented type: " << field->cpp_type();
}
if (unsafe_shallow_swap) {
// Not clearing oneof case after move may cause unwanted "ClearOneof"
@ -598,7 +599,7 @@ void SwapFieldHelper::SwapInlinedStrings(const Reflection* r, Message* lhs,
auto* lhs_string = r->MutableRaw<InlinedStringField>(lhs, field);
auto* rhs_string = r->MutableRaw<InlinedStringField>(rhs, field);
uint32_t index = r->schema_.InlinedStringIndex(field);
GOOGLE_DCHECK_GT(index, 0);
GOOGLE_ABSL_DCHECK_GT(index, 0);
uint32_t* lhs_array = r->MutableInlinedStringDonatedArray(lhs);
uint32_t* rhs_array = r->MutableInlinedStringDonatedArray(rhs);
uint32_t* lhs_state = &lhs_array[index / 32];
@ -769,7 +770,7 @@ void SwapFieldHelper::SwapNonMessageNonStringField(
SWAP_VALUES(ENUM, int);
#undef SWAP_VALUES
default:
GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
GOOGLE_ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
}
}
@ -805,7 +806,7 @@ void Reflection::SwapField(Message* message1, Message* message2,
break;
default:
GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
GOOGLE_ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
}
} else {
switch (field->cpp_type()) {
@ -868,7 +869,7 @@ void Reflection::UnsafeShallowSwapField(Message* message1, Message* message2,
break;
default:
GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
GOOGLE_ABSL_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
}
}
@ -962,7 +963,7 @@ void Reflection::SwapOneofField(Message* lhs, Message* rhs,
const FieldDescriptor* field;
};
GOOGLE_DCHECK(!oneof_descriptor->is_synthetic());
GOOGLE_ABSL_DCHECK(!oneof_descriptor->is_synthetic());
uint32_t oneof_case_lhs = GetOneofCase(*lhs, oneof_descriptor);
uint32_t oneof_case_rhs = GetOneofCase(*rhs, oneof_descriptor);
@ -1003,7 +1004,7 @@ void Reflection::Swap(Message* message1, Message* message2) const {
if (message1 == message2) return;
// TODO(kenton): Other Reflection methods should probably check this too.
GOOGLE_CHECK_EQ(message1->GetReflection(), this)
GOOGLE_ABSL_CHECK_EQ(message1->GetReflection(), this)
<< "First argument to Swap() (of type \""
<< message1->GetDescriptor()->full_name()
<< "\") is not compatible with this reflection object (which is for type "
@ -1011,7 +1012,7 @@ void Reflection::Swap(Message* message1, Message* message2) const {
<< descriptor_->full_name()
<< "\"). Note that the exact same class is required; not just the same "
"descriptor.";
GOOGLE_CHECK_EQ(message2->GetReflection(), this)
GOOGLE_ABSL_CHECK_EQ(message2->GetReflection(), this)
<< "Second argument to Swap() (of type \""
<< message2->GetDescriptor()->full_name()
<< "\") is not compatible with this reflection object (which is for type "
@ -1058,7 +1059,7 @@ void Reflection::SwapFieldsImpl(
if (message1 == message2) return;
// TODO(kenton): Other Reflection methods should probably check this too.
GOOGLE_CHECK_EQ(message1->GetReflection(), this)
GOOGLE_ABSL_CHECK_EQ(message1->GetReflection(), this)
<< "First argument to SwapFields() (of type \""
<< message1->GetDescriptor()->full_name()
<< "\") is not compatible with this reflection object (which is for type "
@ -1066,7 +1067,7 @@ void Reflection::SwapFieldsImpl(
<< descriptor_->full_name()
<< "\"). Note that the exact same class is required; not just the same "
"descriptor.";
GOOGLE_CHECK_EQ(message2->GetReflection(), this)
GOOGLE_ABSL_CHECK_EQ(message2->GetReflection(), this)
<< "Second argument to SwapFields() (of type \""
<< message2->GetDescriptor()->full_name()
<< "\") is not compatible with this reflection object (which is for type "
@ -1113,9 +1114,9 @@ void Reflection::SwapFieldsImpl(
SwapBit(message1, message2, field);
if (field->options().ctype() == FieldOptions::STRING &&
IsInlined(field)) {
GOOGLE_DCHECK(!unsafe_shallow_swap ||
message1->GetArenaForAllocation() ==
message2->GetArenaForAllocation());
GOOGLE_ABSL_DCHECK(!unsafe_shallow_swap ||
message1->GetArenaForAllocation() ==
message2->GetArenaForAllocation());
SwapInlinedStringDonated(message1, message2, field);
}
}
@ -1133,8 +1134,8 @@ void Reflection::SwapFields(
void Reflection::UnsafeShallowSwapFields(
Message* message1, Message* message2,
const std::vector<const FieldDescriptor*>& fields) const {
GOOGLE_DCHECK_EQ(message1->GetArenaForAllocation(),
message2->GetArenaForAllocation());
GOOGLE_ABSL_DCHECK_EQ(message1->GetArenaForAllocation(),
message2->GetArenaForAllocation());
SwapFieldsImpl<true>(message1, message2, fields);
}
@ -1142,7 +1143,7 @@ void Reflection::UnsafeShallowSwapFields(
void Reflection::UnsafeArenaSwapFields(
Message* lhs, Message* rhs,
const std::vector<const FieldDescriptor*>& fields) const {
GOOGLE_DCHECK_EQ(lhs->GetArenaForAllocation(), rhs->GetArenaForAllocation());
GOOGLE_ABSL_DCHECK_EQ(lhs->GetArenaForAllocation(), rhs->GetArenaForAllocation());
UnsafeShallowSwapFields(lhs, rhs, fields);
}
@ -1166,7 +1167,7 @@ bool Reflection::HasField(const Message& message,
}
void Reflection::UnsafeArenaSwap(Message* lhs, Message* rhs) const {
GOOGLE_DCHECK_EQ(lhs->GetOwningArena(), rhs->GetOwningArena());
GOOGLE_ABSL_DCHECK_EQ(lhs->GetOwningArena(), rhs->GetOwningArena());
InternalSwap(lhs, rhs);
}
@ -1236,8 +1237,8 @@ void Reflection::InternalSwap(Message* lhs, Message* rhs) const {
? 0
// One extra bit for the arena dtor tracking.
: (inlined_string_count + 1 + 31) / 32;
GOOGLE_CHECK_EQ((lhs_donated_array[0] & 0x1u) == 0,
(rhs_donated_array[0] & 0x1u) == 0);
GOOGLE_ABSL_CHECK_EQ((lhs_donated_array[0] & 0x1u) == 0,
(rhs_donated_array[0] & 0x1u) == 0);
for (int i = 0; i < donated_array_size; i++) {
std::swap(lhs_donated_array[i], rhs_donated_array[i]);
}
@ -1289,7 +1290,7 @@ int Reflection::FieldSize(const Message& message,
}
}
GOOGLE_LOG(FATAL) << "Can't get here.";
GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return 0;
}
}
@ -1550,7 +1551,7 @@ struct FieldNumberSorter {
};
bool IsIndexInHasBitSet(const uint32_t* has_bit_set, uint32_t has_bit_index) {
GOOGLE_DCHECK_NE(has_bit_index, ~0u);
GOOGLE_ABSL_DCHECK_NE(has_bit_index, ~0u);
return ((has_bit_set[has_bit_index / 32] >> (has_bit_index % 32)) &
static_cast<uint32_t>(1)) != 0;
}
@ -1771,7 +1772,7 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
case FieldOptions::STRING: {
if (IsInlined(field)) {
const uint32_t index = schema_.InlinedStringIndex(field);
GOOGLE_DCHECK_GT(index, 0);
GOOGLE_ABSL_DCHECK_GT(index, 0);
uint32_t* states =
&MutableInlinedStringDonatedArray(message)[index / 32];
uint32_t mask = ~(static_cast<uint32_t>(1) << (index % 32));
@ -2150,8 +2151,9 @@ void Reflection::UnsafeArenaSetAllocatedMessage(
void Reflection::SetAllocatedMessage(Message* message, Message* sub_message,
const FieldDescriptor* field) const {
GOOGLE_DCHECK(sub_message == nullptr || sub_message->GetOwningArena() == nullptr ||
sub_message->GetOwningArena() == message->GetArenaForAllocation());
GOOGLE_ABSL_DCHECK(
sub_message == nullptr || sub_message->GetOwningArena() == nullptr ||
sub_message->GetOwningArena() == message->GetArenaForAllocation());
CheckInvalidAccess(schema_, field);
// If message and sub-message are in different memory ownership domains
@ -2367,7 +2369,7 @@ void* Reflection::MutableRawRepeatedField(Message* message,
ReportReflectionUsageTypeError(descriptor_, field,
"MutableRawRepeatedField", cpptype);
if (desc != nullptr)
GOOGLE_CHECK_EQ(field->message_type(), desc) << "wrong submessage type";
GOOGLE_ABSL_CHECK_EQ(field->message_type(), desc) << "wrong submessage type";
if (field->is_extension()) {
return MutableExtensionSet(message)->MutableRawRepeatedField(
field->number(), field->type(), field->is_packed(), field);
@ -2391,9 +2393,9 @@ const void* Reflection::GetRawRepeatedField(const Message& message,
ReportReflectionUsageTypeError(descriptor_, field, "GetRawRepeatedField",
cpptype);
if (ctype >= 0)
GOOGLE_CHECK_EQ(field->options().ctype(), ctype) << "subtype mismatch";
GOOGLE_ABSL_CHECK_EQ(field->options().ctype(), ctype) << "subtype mismatch";
if (desc != nullptr)
GOOGLE_CHECK_EQ(field->message_type(), desc) << "wrong submessage type";
GOOGLE_ABSL_CHECK_EQ(field->message_type(), desc) << "wrong submessage type";
if (field->is_extension()) {
// Should use extension_set::GetRawRepeatedField. However, the required
// parameter "default repeated value" is not very easy to get here.
@ -2517,7 +2519,7 @@ const Type& Reflection::GetRawNonOneof(const Message& message,
}
void Reflection::PrepareSplitMessageForWrite(Message* message) const {
GOOGLE_DCHECK_NE(message, schema_.default_instance_);
GOOGLE_ABSL_DCHECK_NE(message, schema_.default_instance_);
void** split = MutableSplitField(message);
const void* default_split = GetSplitField(schema_.default_instance_);
if (*split == default_split) {
@ -2553,18 +2555,18 @@ Type* Reflection::MutableRaw(Message* message,
}
const uint32_t* Reflection::GetHasBits(const Message& message) const {
GOOGLE_DCHECK(schema_.HasHasbits());
GOOGLE_ABSL_DCHECK(schema_.HasHasbits());
return &GetConstRefAtOffset<uint32_t>(message, schema_.HasBitsOffset());
}
uint32_t* Reflection::MutableHasBits(Message* message) const {
GOOGLE_DCHECK(schema_.HasHasbits());
GOOGLE_ABSL_DCHECK(schema_.HasHasbits());
return GetPointerAtOffset<uint32_t>(message, schema_.HasBitsOffset());
}
uint32_t* Reflection::MutableOneofCase(
Message* message, const OneofDescriptor* oneof_descriptor) const {
GOOGLE_DCHECK(!oneof_descriptor->is_synthetic());
GOOGLE_ABSL_DCHECK(!oneof_descriptor->is_synthetic());
return GetPointerAtOffset<uint32_t>(
message, schema_.GetOneofCaseOffset(oneof_descriptor));
}
@ -2592,13 +2594,13 @@ InternalMetadata* Reflection::MutableInternalMetadata(Message* message) const {
const uint32_t* Reflection::GetInlinedStringDonatedArray(
const Message& message) const {
GOOGLE_DCHECK(schema_.HasInlinedString());
GOOGLE_ABSL_DCHECK(schema_.HasInlinedString());
return &GetConstRefAtOffset<uint32_t>(message,
schema_.InlinedStringDonatedOffset());
}
uint32_t* Reflection::MutableInlinedStringDonatedArray(Message* message) const {
GOOGLE_DCHECK(schema_.HasInlinedString());
GOOGLE_ABSL_DCHECK(schema_.HasInlinedString());
return GetPointerAtOffset<uint32_t>(message,
schema_.InlinedStringDonatedOffset());
}
@ -2607,7 +2609,7 @@ uint32_t* Reflection::MutableInlinedStringDonatedArray(Message* message) const {
bool Reflection::IsInlinedStringDonated(const Message& message,
const FieldDescriptor* field) const {
uint32_t index = schema_.InlinedStringIndex(field);
GOOGLE_DCHECK_GT(index, 0);
GOOGLE_ABSL_DCHECK_GT(index, 0);
return IsIndexInHasBitSet(GetInlinedStringDonatedArray(message), index);
}
@ -2636,11 +2638,11 @@ void Reflection::SwapInlinedStringDonated(Message* lhs, Message* rhs,
// If one is undonated, both must have already registered ArenaDtor.
uint32_t* lhs_array = MutableInlinedStringDonatedArray(lhs);
uint32_t* rhs_array = MutableInlinedStringDonatedArray(rhs);
GOOGLE_CHECK_EQ(lhs_array[0] & 0x1u, 0u);
GOOGLE_CHECK_EQ(rhs_array[0] & 0x1u, 0u);
GOOGLE_ABSL_CHECK_EQ(lhs_array[0] & 0x1u, 0u);
GOOGLE_ABSL_CHECK_EQ(rhs_array[0] & 0x1u, 0u);
// Swap donation status bit.
uint32_t index = schema_.InlinedStringIndex(field);
GOOGLE_DCHECK_GT(index, 0);
GOOGLE_ABSL_DCHECK_GT(index, 0);
if (rhs_donated) {
SetInlinedStringDonated(index, lhs_array);
ClearInlinedStringDonated(index, rhs_array);
@ -2653,7 +2655,7 @@ void Reflection::SwapInlinedStringDonated(Message* lhs, Message* rhs,
// Simple accessors for manipulating has_bits_.
bool Reflection::HasBit(const Message& message,
const FieldDescriptor* field) const {
GOOGLE_DCHECK(!field->options().weak());
GOOGLE_ABSL_DCHECK(!field->options().weak());
if (schema_.HasBitIndex(field) != static_cast<uint32_t>(-1)) {
return IsIndexInHasBitSet(GetHasBits(message), schema_.HasBitIndex(field));
}
@ -2715,13 +2717,13 @@ bool Reflection::HasBit(const Message& message,
// handled above; avoid warning
break;
}
GOOGLE_LOG(FATAL) << "Reached impossible case in HasBit().";
GOOGLE_ABSL_LOG(FATAL) << "Reached impossible case in HasBit().";
return false;
}
}
void Reflection::SetBit(Message* message, const FieldDescriptor* field) const {
GOOGLE_DCHECK(!field->options().weak());
GOOGLE_ABSL_DCHECK(!field->options().weak());
const uint32_t index = schema_.HasBitIndex(field);
if (index == static_cast<uint32_t>(-1)) return;
MutableHasBits(message)[index / 32] |=
@ -2730,7 +2732,7 @@ void Reflection::SetBit(Message* message, const FieldDescriptor* field) const {
void Reflection::ClearBit(Message* message,
const FieldDescriptor* field) const {
GOOGLE_DCHECK(!field->options().weak());
GOOGLE_ABSL_DCHECK(!field->options().weak());
const uint32_t index = schema_.HasBitIndex(field);
if (index == static_cast<uint32_t>(-1)) return;
MutableHasBits(message)[index / 32] &=
@ -2739,7 +2741,7 @@ void Reflection::ClearBit(Message* message,
void Reflection::SwapBit(Message* message1, Message* message2,
const FieldDescriptor* field) const {
GOOGLE_DCHECK(!field->options().weak());
GOOGLE_ABSL_DCHECK(!field->options().weak());
if (!schema_.HasHasbits()) {
return;
}
@ -2933,15 +2935,15 @@ void* Reflection::RepeatedFieldData(Message* message,
const FieldDescriptor* field,
FieldDescriptor::CppType cpp_type,
const Descriptor* message_type) const {
GOOGLE_CHECK(field->is_repeated());
GOOGLE_CHECK(field->cpp_type() == cpp_type ||
(field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM &&
cpp_type == FieldDescriptor::CPPTYPE_INT32))
GOOGLE_ABSL_CHECK(field->is_repeated());
GOOGLE_ABSL_CHECK(field->cpp_type() == cpp_type ||
(field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM &&
cpp_type == FieldDescriptor::CPPTYPE_INT32))
<< "The type parameter T in RepeatedFieldRef<T> API doesn't match "
<< "the actual field type (for enums T should be the generated enum "
<< "type or int32_t).";
if (message_type != nullptr) {
GOOGLE_CHECK_EQ(message_type, field->message_type());
GOOGLE_ABSL_CHECK_EQ(message_type, field->message_type());
}
if (field->is_extension()) {
return MutableExtensionSet(message)->MutableRawRepeatedField(
@ -3088,7 +3090,7 @@ static internal::TailCallParseFunc GetFastParseFunction(
};
auto it = map->find(name);
if (it == map->end()) {
GOOGLE_LOG(DFATAL) << "Failed to find function: " << name;
GOOGLE_ABSL_LOG(DFATAL) << "Failed to find function: " << name;
// Let's not crash in opt, just in case.
// MiniParse is always a valid parser.
return &internal::TcParser::MiniParse;
@ -3109,8 +3111,8 @@ const internal::TcParseTableBase* Reflection::CreateTcParseTableForMessageSet()
auto* full_table = ::new (p) Table{
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, schema_.default_instance_, nullptr},
{{{&internal::TcParser::ReflectionParseLoop, {}}}}};
GOOGLE_DCHECK_EQ(static_cast<void*>(&full_table->header),
static_cast<void*>(full_table));
GOOGLE_ABSL_DCHECK_EQ(static_cast<void*>(&full_table->header),
static_cast<void*>(full_table));
return &full_table->header;
}
@ -3221,7 +3223,7 @@ void Reflection::PopulateTcParseFieldAux(
case internal::TailCallTableInfo::kSubTable:
case internal::TailCallTableInfo::kSubMessageWeak:
case internal::TailCallTableInfo::kMessageVerifyFunc:
GOOGLE_LOG(FATAL) << "Not supported";
GOOGLE_ABSL_LOG(FATAL) << "Not supported";
break;
case internal::TailCallTableInfo::kSubMessage:
field_aux++->message_default_p =
@ -3232,7 +3234,7 @@ void Reflection::PopulateTcParseFieldAux(
aux_entry.enum_range.size};
break;
case internal::TailCallTableInfo::kEnumValidator:
GOOGLE_LOG(FATAL) << "Not supported.";
GOOGLE_ABSL_LOG(FATAL) << "Not supported.";
break;
case internal::TailCallTableInfo::kNumericOffset:
field_aux++->offset = aux_entry.offset;
@ -3306,7 +3308,7 @@ const internal::TcParseTableBase* Reflection::CreateTcParseTable() const {
inlined_string_indices);
const size_t fast_entries_count = table_info.fast_path_fields.size();
GOOGLE_CHECK_EQ(fast_entries_count, 1 << table_info.table_size_log2);
GOOGLE_ABSL_CHECK_EQ(fast_entries_count, 1 << table_info.table_size_log2);
const uint16_t lookup_table_offset = AlignTo<uint16_t>(
sizeof(TcParseTableBase) +
fast_entries_count * sizeof(TcParseTableBase::FastFieldEntry));
@ -3349,9 +3351,9 @@ const internal::TcParseTableBase* Reflection::CreateTcParseTable() const {
table_info.field_name_data.size());
}
// Validation to make sure we used all the bytes correctly.
GOOGLE_CHECK_EQ(res->name_data() + table_info.field_name_data.size() -
reinterpret_cast<char*>(res),
byte_size);
GOOGLE_ABSL_CHECK_EQ(res->name_data() + table_info.field_name_data.size() -
reinterpret_cast<char*>(res),
byte_size);
return res;
}
@ -3505,7 +3507,7 @@ void AssignDescriptorsImpl(const DescriptorTable* table, bool eager) {
const FileDescriptor* file =
DescriptorPool::internal_generated_pool()->FindFileByName(
table->filename);
GOOGLE_CHECK(file != nullptr);
GOOGLE_ABSL_CHECK(file != nullptr);
MessageFactory* factory = MessageFactory::generated_factory();

@ -140,7 +140,7 @@ struct ReflectionSchema {
// Offset of a non-oneof field. Getting a field offset is slightly more
// efficient when we know statically that it is not a oneof field.
uint32_t GetFieldOffsetNonOneof(const FieldDescriptor* field) const {
GOOGLE_DCHECK(!InRealOneof(field));
GOOGLE_ABSL_DCHECK(!InRealOneof(field));
return OffsetValue(offsets_[field->index()], field->type());
}
@ -172,13 +172,13 @@ struct ReflectionSchema {
// Bit index within the bit array of hasbits. Bit order is low-to-high.
uint32_t HasBitIndex(const FieldDescriptor* field) const {
if (has_bits_offset_ == -1) return static_cast<uint32_t>(-1);
GOOGLE_DCHECK(HasHasbits());
GOOGLE_ABSL_DCHECK(HasHasbits());
return has_bit_indices_[field->index()];
}
// Byte offset of the hasbits array.
uint32_t HasBitsOffset() const {
GOOGLE_DCHECK(HasHasbits());
GOOGLE_ABSL_DCHECK(HasHasbits());
return static_cast<uint32_t>(has_bits_offset_);
}
@ -187,13 +187,13 @@ struct ReflectionSchema {
// Bit index within the bit array of _inlined_string_donated_. Bit order is
// low-to-high.
uint32_t InlinedStringIndex(const FieldDescriptor* field) const {
GOOGLE_DCHECK(HasInlinedString());
GOOGLE_ABSL_DCHECK(HasInlinedString());
return inlined_string_indices_[field->index()];
}
// Byte offset of the _inlined_string_donated_ array.
uint32_t InlinedStringDonatedOffset() const {
GOOGLE_DCHECK(HasInlinedString());
GOOGLE_ABSL_DCHECK(HasInlinedString());
return static_cast<uint32_t>(inlined_string_donated_offset_);
}
@ -210,7 +210,7 @@ struct ReflectionSchema {
// The offset of the ExtensionSet in this message.
uint32_t GetExtensionSetOffset() const {
GOOGLE_DCHECK(HasExtensionSet());
GOOGLE_ABSL_DCHECK(HasExtensionSet());
return static_cast<uint32_t>(extensions_offset_);
}
@ -231,7 +231,7 @@ struct ReflectionSchema {
// Returns true if the field is implicitly backed by LazyField.
bool IsEagerlyVerifiedLazyField(const FieldDescriptor* field) const {
GOOGLE_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_MESSAGE);
GOOGLE_ABSL_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_MESSAGE);
(void)field;
return false;
}
@ -255,12 +255,12 @@ struct ReflectionSchema {
// Byte offset of _split_.
uint32_t SplitOffset() const {
GOOGLE_DCHECK(IsSplit());
GOOGLE_ABSL_DCHECK(IsSplit());
return static_cast<uint32_t>(split_offset_);
}
uint32_t SizeofSplit() const {
GOOGLE_DCHECK(IsSplit());
GOOGLE_ABSL_DCHECK(IsSplit());
return static_cast<uint32_t>(sizeof_split_);
}

@ -46,11 +46,11 @@
#include <memory>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/cord.h"
#include "google/protobuf/map_test_util.h"
#include "google/protobuf/map_unittest.pb.h"
@ -95,7 +95,7 @@ namespace {
const FieldDescriptor* F(const std::string& name) {
const FieldDescriptor* result =
unittest::TestAllTypes::descriptor()->FindFieldByName(name);
GOOGLE_CHECK(result != nullptr);
GOOGLE_ABSL_CHECK(result != nullptr);
return result;
}

@ -53,7 +53,7 @@ namespace {
bool GetEnumValidationRange(const EnumDescriptor* enum_type, int16_t& start,
uint16_t& size) {
GOOGLE_CHECK_GT(enum_type->value_count(), 0) << enum_type->DebugString();
GOOGLE_ABSL_CHECK_GT(enum_type->value_count(), 0) << enum_type->DebugString();
// Check if the enum values are a single, contiguous range.
std::vector<int> enum_values;
@ -149,7 +149,7 @@ void PopulateFastFieldEntry(const TailCallTableInfo::FieldEntryInfo& entry,
name.append("c");
} else if (options.is_string_inlined) {
name.append("i");
GOOGLE_CHECK(!field->is_repeated());
GOOGLE_ABSL_CHECK(!field->is_repeated());
aux_idx = static_cast<uint8_t>(entry.inlined_string_idx);
}
}
@ -205,7 +205,7 @@ bool IsFieldEligibleForFastParsing(
return false;
}
if (options.is_string_inlined) {
GOOGLE_CHECK(!field->is_repeated());
GOOGLE_ABSL_CHECK(!field->is_repeated());
// For inlined strings, the donation state index is stored in the
// `aux_idx` field of the fast parsing info. We need to check the range
// of that value instead of the auxiliary index.
@ -220,7 +220,7 @@ bool IsFieldEligibleForFastParsing(
if (cpp::HasHasbit(field)) {
// The tailcall parser can only update the first 32 hasbits. Fields with
// has-bits beyond the first 32 are handled by mini parsing/fallback.
GOOGLE_CHECK_GE(entry.hasbit_idx, 0) << field->DebugString();
GOOGLE_ABSL_CHECK_GE(entry.hasbit_idx, 0) << field->DebugString();
if (entry.hasbit_idx >= 32) return false;
}
@ -255,7 +255,7 @@ absl::optional<uint32_t> GetEndGroupTag(const Descriptor* descriptor) {
}
uint32_t RecodeTagForFastParsing(uint32_t tag) {
GOOGLE_DCHECK_LE(tag, 0x3FFF);
GOOGLE_ABSL_DCHECK_LE(tag, 0x3FFF);
// Construct the varint-coded tag. If it is more than 7 bits, we need to
// shift the high bits and add a continue bit.
if (uint32_t hibits = tag & 0xFFFFFF80) {
@ -318,7 +318,7 @@ std::vector<TailCallTableInfo::FastFieldInfo> SplitFastFieldsForSize(
}
// Fill in this field's entry:
GOOGLE_CHECK(info.func_name.empty()) << info.func_name;
GOOGLE_ABSL_CHECK(info.func_name.empty()) << info.func_name;
PopulateFastFieldEntry(entry, options, info);
info.field = field;
info.coded_tag = tag;
@ -486,7 +486,7 @@ TailCallTableInfo::NumToEntryTable MakeNumToEntryTable(
for (; field_entry_index != N; ++field_entry_index) {
auto* field_descriptor = field_descriptors[field_entry_index];
uint32_t fnum = static_cast<uint32_t>(field_descriptor->number());
GOOGLE_CHECK_GT(fnum, last_skip_entry_start);
GOOGLE_ABSL_CHECK_GT(fnum, last_skip_entry_start);
if (start_new_block == false) {
// If the next field number is within 15 of the last_skip_entry_start, we
// continue writing just to that entry. If it's between 16 and 31 more,
@ -653,8 +653,8 @@ uint16_t MakeTypeCardForField(
} else {
type_card |= fl::kMessage;
if (options.lazy_opt != 0) {
GOOGLE_CHECK(options.lazy_opt == field_layout::kTvEager ||
options.lazy_opt == field_layout::kTvLazy);
GOOGLE_ABSL_CHECK(options.lazy_opt == field_layout::kTvEager ||
options.lazy_opt == field_layout::kTvLazy);
type_card |= +fl::kRepLazy | options.lazy_opt;
} else {
if (options.is_implicitly_weak) {
@ -774,7 +774,7 @@ TailCallTableInfo::TailCallTableInfo(
} else if ((field->type() == FieldDescriptor::TYPE_STRING ||
field->type() == FieldDescriptor::TYPE_BYTES) &&
options.is_string_inlined) {
GOOGLE_CHECK(!field->is_repeated());
GOOGLE_ABSL_CHECK(!field->is_repeated());
// Inlined strings have an extra marker to represent their donation state.
int idx = inlined_string_indices[static_cast<size_t>(field->index())];
// For mini parsing, the donation state index is stored as an `offset`
@ -795,7 +795,7 @@ TailCallTableInfo::TailCallTableInfo(
size_t try_size = 1 << try_size_log2;
auto split_fields = SplitFastFieldsForSize(end_group_tag, field_entries,
try_size_log2, option_provider);
GOOGLE_CHECK_EQ(split_fields.size(), try_size);
GOOGLE_ABSL_CHECK_EQ(split_fields.size(), try_size);
int try_num_fast_fields = 0;
for (const auto& info : split_fields) {
if (info.field != nullptr) ++try_num_fast_fields;
@ -831,7 +831,7 @@ TailCallTableInfo::TailCallTableInfo(
fallback_fields = FilterMiniParsedFields(ordered_fields, option_provider);
num_to_entry_table = MakeNumToEntryTable(ordered_fields);
GOOGLE_CHECK_EQ(field_entries.size(), ordered_fields.size());
GOOGLE_ABSL_CHECK_EQ(field_entries.size(), ordered_fields.size());
field_name_data = GenerateFieldNames(descriptor, field_entries);
// If there are no fallback fields, and at most one extension range, the

@ -265,7 +265,7 @@ enum FieldType : uint16_t {
#ifndef NDEBUG
template <size_t align>
void AlignFail(uintptr_t address) {
GOOGLE_LOG(FATAL) << "Unaligned (" << align << ") access at " << address;
GOOGLE_ABSL_LOG(FATAL) << "Unaligned (" << align << ") access at " << address;
// Explicit abort to let compilers know this function does not return
abort();

@ -467,7 +467,7 @@ PROTOBUF_NOINLINE const char* TcParser::FastGtS2(PROTOBUF_TC_PARAM_DECL) {
template <typename TagType>
const char* TcParser::LazyMessage(PROTOBUF_TC_PARAM_DECL) {
GOOGLE_LOG(FATAL) << "Unimplemented";
GOOGLE_ABSL_LOG(FATAL) << "Unimplemented";
return nullptr;
}
@ -741,7 +741,7 @@ Parse64FallbackPair(const char* p, int64_t res1) {
// On x86-64, a shld from a single register filled with enough 1s in the high
// bits can accomplish all this in one instruction. It so happens that res1
// has 57 high bits of ones, which is enough for the largest shift done.
GOOGLE_DCHECK_EQ(res1 >> 7, -1);
GOOGLE_ABSL_DCHECK_EQ(res1 >> 7, -1);
uint64_t ones = res1; // save the high 1 bits from res1 (input to SHLD)
int64_t res2, res3; // accumulated result chunks
@ -1783,8 +1783,8 @@ bool TcParser::ChangeOneof(const TcParseTableBase* table,
case field_layout::kRepSString:
case field_layout::kRepIString:
default:
GOOGLE_LOG(DFATAL) << "string rep not handled: "
<< (current_rep >> field_layout::kRepShift);
GOOGLE_ABSL_LOG(DFATAL) << "string rep not handled: "
<< (current_rep >> field_layout::kRepShift);
return true;
}
} else if (current_kind == field_layout::kFkMessage) {
@ -1798,8 +1798,8 @@ bool TcParser::ChangeOneof(const TcParseTableBase* table,
break;
}
default:
GOOGLE_LOG(DFATAL) << "message rep not handled: "
<< (current_rep >> field_layout::kRepShift);
GOOGLE_ABSL_LOG(DFATAL) << "message rep not handled: "
<< (current_rep >> field_layout::kRepShift);
break;
}
}
@ -1855,7 +1855,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpFixed(PROTOBUF_TC_PARAM_DECL) {
PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
}
} else {
GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits));
GOOGLE_ABSL_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits));
if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED32) {
PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
}
@ -1907,7 +1907,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpRepeatedFixed(
ptr2 = ReadTag(ptr, &next_tag);
} while (next_tag == decoded_tag);
} else {
GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits));
GOOGLE_ABSL_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits));
if (decoded_wiretype != WireFormatLite::WIRETYPE_FIXED32) {
PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
}
@ -1947,7 +1947,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpPackedFixed(PROTOBUF_TC_PARAM_DECL) {
auto& field = RefAt<RepeatedField<uint64_t>>(msg, entry.offset);
ptr = ctx->ReadPackedFixed(ptr, size, &field);
} else {
GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits));
GOOGLE_ABSL_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep32Bits));
auto& field = RefAt<RepeatedField<uint32_t>>(msg, entry.offset);
ptr = ctx->ReadPackedFixed(ptr, size, &field);
}
@ -2013,7 +2013,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpVarint(PROTOBUF_TC_PARAM_DECL) {
} else if (rep == field_layout::kRep32Bits) {
RefAt<uint32_t>(base, entry.offset) = static_cast<uint32_t>(tmp);
} else {
GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits));
GOOGLE_ABSL_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits));
RefAt<bool>(base, entry.offset) = static_cast<bool>(tmp);
}
@ -2075,7 +2075,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpRepeatedVarint(
if (ptr2 == nullptr) return Error(PROTOBUF_TC_PARAM_PASS);
} while (next_tag == decoded_tag);
} else {
GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits));
GOOGLE_ABSL_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits));
auto& field = RefAt<RepeatedField<bool>>(msg, entry.offset);
const char* ptr2 = ptr;
uint32_t next_tag;
@ -2135,7 +2135,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpPackedVarint(PROTOBUF_TC_PARAM_DECL) {
});
}
} else {
GOOGLE_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits));
GOOGLE_ABSL_DCHECK_EQ(rep, static_cast<uint16_t>(field_layout::kRep8Bits));
auto* field = &RefAt<RepeatedField<bool>>(msg, entry.offset);
return ctx->ReadPackedVarint(
ptr, [field](uint64_t value) { field->Add(value); });
@ -2293,7 +2293,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpRepeatedString(
#ifndef NDEBUG
default:
GOOGLE_LOG(FATAL) << "Unsupported repeated string rep: " << rep;
GOOGLE_ABSL_LOG(FATAL) << "Unsupported repeated string rep: " << rep;
break;
#endif
}
@ -2302,7 +2302,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpRepeatedString(
}
const char* TcParser::MpLazyMessage(PROTOBUF_TC_PARAM_DECL) {
GOOGLE_LOG(FATAL) << "Unimplemented";
GOOGLE_ABSL_LOG(FATAL) << "Unimplemented";
return nullptr;
}
@ -2369,7 +2369,8 @@ PROTOBUF_NOINLINE const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) {
if ((type_card & field_layout::kTvMask) == field_layout::kTvDefault) {
def = table->field_aux(&entry)->message_default();
} else {
GOOGLE_DCHECK_EQ(type_card & field_layout::kTvMask, +field_layout::kTvWeakPtr);
GOOGLE_ABSL_DCHECK_EQ(type_card & field_layout::kTvMask,
+field_layout::kTvWeakPtr);
def = table->field_aux(&entry)->message_default_weak();
}
field = def->New(msg->GetArenaForAllocation());
@ -2384,8 +2385,8 @@ PROTOBUF_NOINLINE const char* TcParser::MpMessage(PROTOBUF_TC_PARAM_DECL) {
const char* TcParser::MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL) {
const auto& entry = RefAt<FieldEntry>(table, data.entry_offset());
const uint16_t type_card = entry.type_card;
GOOGLE_DCHECK_EQ(type_card & field_layout::kFcMask,
static_cast<uint16_t>(field_layout::kFcRepeated));
GOOGLE_ABSL_DCHECK_EQ(type_card & field_layout::kFcMask,
static_cast<uint16_t>(field_layout::kFcRepeated));
const uint32_t decoded_tag = data.tag();
const uint32_t decoded_wiretype = decoded_tag & 7;
const uint16_t rep = type_card & field_layout::kRepMask;
@ -2427,7 +2428,8 @@ const char* TcParser::MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL) {
if ((type_card & field_layout::kTvMask) == field_layout::kTvDefault) {
def = aux.message_default();
} else {
GOOGLE_DCHECK_EQ(type_card & field_layout::kTvMask, +field_layout::kTvWeakPtr);
GOOGLE_ABSL_DCHECK_EQ(type_card & field_layout::kTvMask,
+field_layout::kTvWeakPtr);
def = aux.message_default_weak();
}
MessageLite* value = field.Add<GenericTypeHandler<MessageLite>>(def);

@ -163,7 +163,7 @@ TEST_F(FindFieldEntryTest, SequentialFieldRange) {
IsEntryForFieldNum(&table, i, table_field_numbers));
}
for (int i : {0, 1, 6, 7, 110, 112, 500000000}) {
GOOGLE_LOG(WARNING) << "Field " << i;
GOOGLE_ABSL_LOG(WARNING) << "Field " << i;
EXPECT_THAT(FindFieldEntry(table, i), Eq(nullptr));
}
}

@ -317,7 +317,7 @@ class AccessorHelper {
};
void SerializeNotImplemented(int field) {
GOOGLE_LOG(FATAL) << "Not implemented field number " << field;
GOOGLE_ABSL_LOG(FATAL) << "Not implemented field number " << field;
}
// When switching to c++11 we should make these constexpr functions
@ -389,9 +389,9 @@ void GenericSwap(MessageLite* m1, MessageLite* m2) {
MessageLite* GetOwnedMessageInternal(Arena* message_arena,
MessageLite* submessage,
Arena* submessage_arena) {
GOOGLE_DCHECK(Arena::InternalGetOwningArena(submessage) == submessage_arena);
GOOGLE_DCHECK(message_arena != submessage_arena);
GOOGLE_DCHECK_EQ(submessage_arena, nullptr);
GOOGLE_ABSL_DCHECK(Arena::InternalGetOwningArena(submessage) == submessage_arena);
GOOGLE_ABSL_DCHECK(message_arena != submessage_arena);
GOOGLE_ABSL_DCHECK_EQ(submessage_arena, nullptr);
if (message_arena != nullptr && submessage_arena == nullptr) {
message_arena->Own(submessage);
return submessage;

@ -34,8 +34,8 @@
#include <string>
#include <utility>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/port.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/arenastring.h"
#include "google/protobuf/message_lite.h"

@ -38,9 +38,9 @@
#include <utility>
#include <vector>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/arenastring.h"
#include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"

@ -59,7 +59,7 @@ inline int GetInitDepth(LazyVerifyOption option) {
template <typename T>
inline bool ParseWithOuterContextImpl(const T& input, LazyVerifyOption option,
ParseContext* ctx, MessageLite* message) {
GOOGLE_DCHECK(ctx == nullptr || !ctx->AliasingEnabled());
GOOGLE_ABSL_DCHECK(ctx == nullptr || !ctx->AliasingEnabled());
// Create local context with depth.
const char* ptr;
@ -137,9 +137,10 @@ bool LazyField::ParseWithOuterContext(MessageLite* message,
}
void LazyField::LogParseError(const MessageLite* message) {
GOOGLE_LOG_EVERY_N(INFO, 100) << "Lazy parsing failed for " << message->GetTypeName()
<< " error=" << message->InitializationErrorString()
<< " (N = " << COUNTER << ")";
GOOGLE_ABSL_LOG_EVERY_N(INFO, 100)
<< "Lazy parsing failed for " << message->GetTypeName()
<< " error=" << message->InitializationErrorString()
<< " (N = " << COUNTER << ")";
}
} // namespace internal

@ -35,8 +35,8 @@
#include <string>
#include <utility>
#include "google/protobuf/stubs/logging.h"
#include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/arena_test_util.h"

@ -292,7 +292,7 @@ inline bool TableEntryIsTooLong(NodeBase* node) {
node = node->next;
} while (node != nullptr);
// Invariant: no linked list ever is more than kMaxLength in length.
GOOGLE_DCHECK_LE(count, kMaxLength);
GOOGLE_ABSL_DCHECK_LE(count, kMaxLength);
return count >= kMaxLength;
}
@ -331,21 +331,21 @@ inline bool TableEntryIsNonEmptyList(TableEntryPtr entry) {
return !TableEntryIsEmpty(entry) && TableEntryIsList(entry);
}
inline NodeBase* TableEntryToNode(TableEntryPtr entry) {
GOOGLE_DCHECK(TableEntryIsList(entry));
GOOGLE_ABSL_DCHECK(TableEntryIsList(entry));
return reinterpret_cast<NodeBase*>(static_cast<uintptr_t>(entry));
}
inline TableEntryPtr NodeToTableEntry(NodeBase* node) {
GOOGLE_DCHECK((reinterpret_cast<uintptr_t>(node) & 1) == 0);
GOOGLE_ABSL_DCHECK((reinterpret_cast<uintptr_t>(node) & 1) == 0);
return static_cast<TableEntryPtr>(reinterpret_cast<uintptr_t>(node));
}
template <typename Tree>
Tree* TableEntryToTree(TableEntryPtr entry) {
GOOGLE_DCHECK(TableEntryIsTree(entry));
GOOGLE_ABSL_DCHECK(TableEntryIsTree(entry));
return reinterpret_cast<Tree*>(static_cast<uintptr_t>(entry) - 1);
}
template <typename Tree>
TableEntryPtr TreeToTableEntry(Tree* node) {
GOOGLE_DCHECK((reinterpret_cast<uintptr_t>(node) & 1) == 0);
GOOGLE_ABSL_DCHECK((reinterpret_cast<uintptr_t>(node) & 1) == 0);
return static_cast<TableEntryPtr>(reinterpret_cast<uintptr_t>(node) | 1);
}
@ -482,8 +482,8 @@ class KeyMapBase {
// Advance through buckets, looking for the first that isn't empty.
// If nothing non-empty is found then leave node_ == nullptr.
void SearchFrom(size_type start_bucket) {
GOOGLE_DCHECK(m_->index_of_first_non_null_ == m_->num_buckets_ ||
!m_->TableEntryIsEmpty(m_->index_of_first_non_null_));
GOOGLE_ABSL_DCHECK(m_->index_of_first_non_null_ == m_->num_buckets_ ||
!m_->TableEntryIsEmpty(m_->index_of_first_non_null_));
for (size_type i = start_bucket; i < m_->num_buckets_; ++i) {
TableEntryPtr entry = m_->table_[i];
if (entry == TableEntryPtr{}) continue;
@ -492,7 +492,7 @@ class KeyMapBase {
node_ = static_cast<KeyNode*>(TableEntryToNode(entry));
} else {
Tree* tree = TableEntryToTree<Tree>(entry);
GOOGLE_DCHECK(!tree->empty());
GOOGLE_ABSL_DCHECK(!tree->empty());
node_ = static_cast<KeyNode*>(tree->begin()->second);
}
return;
@ -547,12 +547,12 @@ class KeyMapBase {
TreeIterator tree_it;
const bool is_list = revalidate_if_necessary(b, node, &tree_it);
if (is_list) {
GOOGLE_DCHECK(TableEntryIsNonEmptyList(b));
GOOGLE_ABSL_DCHECK(TableEntryIsNonEmptyList(b));
auto* head = TableEntryToNode(table_[b]);
head = EraseFromLinkedList(node, head);
table_[b] = NodeToTableEntry(head);
} else {
GOOGLE_DCHECK(this->TableEntryIsTree(b));
GOOGLE_ABSL_DCHECK(this->TableEntryIsTree(b));
Tree* tree = internal::TableEntryToTree<Tree>(this->table_[b]);
if (tree_it != tree->begin()) {
auto* prev = std::prev(tree_it)->second;
@ -609,13 +609,13 @@ class KeyMapBase {
// Requires count(*KeyPtrFromNodePtr(node)) == 0 and that b is the correct
// bucket. num_elements_ is not modified.
void InsertUnique(size_type b, KeyNode* node) {
GOOGLE_DCHECK(index_of_first_non_null_ == num_buckets_ ||
!TableEntryIsEmpty(index_of_first_non_null_));
GOOGLE_ABSL_DCHECK(index_of_first_non_null_ == num_buckets_ ||
!TableEntryIsEmpty(index_of_first_non_null_));
// In practice, the code that led to this point may have already
// determined whether we are inserting into an empty list, a short list,
// or whatever. But it's probably cheap enough to recompute that here;
// it's likely that we're inserting into an empty or short list.
GOOGLE_DCHECK(FindHelper(node->key()).node == nullptr);
GOOGLE_ABSL_DCHECK(FindHelper(node->key()).node == nullptr);
if (TableEntryIsEmpty(b)) {
InsertUniqueInList(b, node);
index_of_first_non_null_ = (std::min)(index_of_first_non_null_, b);
@ -625,7 +625,7 @@ class KeyMapBase {
if (TableEntryIsNonEmptyList(b)) {
TreeConvert(b);
}
GOOGLE_DCHECK(TableEntryIsTree(b))
GOOGLE_ABSL_DCHECK(TableEntryIsTree(b))
<< (void*)table_[b] << " " << (uintptr_t)table_[b];
InsertUniqueInTree(b, node);
index_of_first_non_null_ = (std::min)(index_of_first_non_null_, b);
@ -725,7 +725,7 @@ class KeyMapBase {
return;
}
GOOGLE_DCHECK_GE(new_num_buckets, kMinTableSize);
GOOGLE_ABSL_DCHECK_GE(new_num_buckets, kMinTableSize);
const auto old_table = table_;
const size_type old_table_size = num_buckets_;
num_buckets_ = new_num_buckets;
@ -772,12 +772,12 @@ class KeyMapBase {
}
void TreeConvert(size_type b) {
GOOGLE_DCHECK(!TableEntryIsTree(b));
GOOGLE_ABSL_DCHECK(!TableEntryIsTree(b));
Tree* tree =
Arena::Create<Tree>(alloc_.arena(), typename Tree::key_compare(),
typename Tree::allocator_type(alloc_));
size_type count = CopyListToTree(b, tree);
GOOGLE_DCHECK_EQ(count, tree->size());
GOOGLE_ABSL_DCHECK_EQ(count, tree->size());
table_[b] = TreeToTableEntry(tree);
// Relink the nodes.
NodeBase* next = nullptr;
@ -852,8 +852,8 @@ class KeyMapBase {
}
TableEntryPtr* CreateEmptyTable(size_type n) {
GOOGLE_DCHECK(n >= kMinTableSize);
GOOGLE_DCHECK_EQ(n & (n - 1), 0u);
GOOGLE_ABSL_DCHECK(n >= kMinTableSize);
GOOGLE_ABSL_DCHECK_EQ(n & (n - 1), 0u);
TableEntryPtr* result = Alloc<TableEntryPtr>(n);
memset(result, 0, n * sizeof(result[0]));
return result;
@ -1197,7 +1197,7 @@ class Map {
}
void erase(iterator it) {
GOOGLE_DCHECK_EQ(it.m_, this);
GOOGLE_ABSL_DCHECK_EQ(it.m_, this);
auto* node = static_cast<Node*>(it.node_);
this->erase_no_destroy(it.bucket_index_, node);
DestroyNode(node);
@ -1407,14 +1407,14 @@ class Map {
template <typename K = key_type>
const T& at(const key_arg<K>& key) const {
const_iterator it = find(key);
GOOGLE_CHECK(it != end()) << "key not found: " << static_cast<Key>(key);
GOOGLE_ABSL_CHECK(it != end()) << "key not found: " << static_cast<Key>(key);
return it->second;
}
template <typename K = key_type>
T& at(const key_arg<K>& key) {
iterator it = find(key);
GOOGLE_CHECK(it != end()) << "key not found: " << static_cast<Key>(key);
GOOGLE_ABSL_CHECK(it != end()) << "key not found: " << static_cast<Key>(key);
return it->second;
}

@ -74,8 +74,8 @@ void MapFieldBase::SwapState(MapFieldBase* other) {
void SwapRepeatedPtrToNull(RepeatedPtrField<Message>** from,
RepeatedPtrField<Message>** to, Arena* from_arena,
Arena* to_arena) {
GOOGLE_DCHECK(*from != nullptr);
GOOGLE_DCHECK(*to == nullptr);
GOOGLE_ABSL_DCHECK(*from != nullptr);
GOOGLE_ABSL_DCHECK(*to == nullptr);
*to = Arena::CreateMessage<RepeatedPtrField<Message> >(to_arena);
**to = std::move(**from);
if (from_arena == nullptr) {
@ -104,7 +104,7 @@ void MapFieldBase::Swap(MapFieldBase* other) {
}
void MapFieldBase::UnsafeShallowSwap(MapFieldBase* other) {
GOOGLE_DCHECK_EQ(arena_, other->arena_);
GOOGLE_ABSL_DCHECK_EQ(arena_, other->arena_);
InternalSwap(other);
}
@ -363,7 +363,7 @@ void DynamicMapField::SetMapIteratorValue(MapIterator* map_iter) const {
}
void DynamicMapField::MergeFrom(const MapFieldBase& other) {
GOOGLE_DCHECK(IsMapValid() && other.IsMapValid());
GOOGLE_ABSL_DCHECK(IsMapValid() && other.IsMapValid());
Map<MapKey, MapValueRef>* map = MutableMap();
const DynamicMapField& other_field =
reinterpret_cast<const DynamicMapField&>(other);
@ -478,7 +478,7 @@ void DynamicMapField::SyncRepeatedFieldWithMapNoLock() const {
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
GOOGLE_LOG(FATAL) << "Can't get here.";
GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
break;
}
const MapValueRef& map_val = it->second;
@ -561,7 +561,7 @@ void DynamicMapField::SyncMapWithRepeatedFieldNoLock() const {
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
GOOGLE_LOG(FATAL) << "Can't get here.";
GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
break;
}

@ -67,13 +67,14 @@ class MapIterator;
#pragma warning(disable : 4265)
#endif // _MSC_VER
#define TYPE_CHECK(EXPECTEDTYPE, METHOD) \
if (type() != EXPECTEDTYPE) { \
GOOGLE_LOG(FATAL) << "Protocol Buffer map usage error:\n" \
<< METHOD << " type does not match\n" \
<< " Expected : " \
<< FieldDescriptor::CppTypeName(EXPECTEDTYPE) << "\n" \
<< " Actual : " << FieldDescriptor::CppTypeName(type()); \
#define TYPE_CHECK(EXPECTEDTYPE, METHOD) \
if (type() != EXPECTEDTYPE) { \
GOOGLE_ABSL_LOG(FATAL) << "Protocol Buffer map usage error:\n" \
<< METHOD << " type does not match\n" \
<< " Expected : " \
<< FieldDescriptor::CppTypeName(EXPECTEDTYPE) << "\n" \
<< " Actual : " \
<< FieldDescriptor::CppTypeName(type()); \
}
// MapKey is an union type for representing any possible
@ -96,9 +97,9 @@ class PROTOBUF_EXPORT MapKey {
FieldDescriptor::CppType type() const {
if (type_ == FieldDescriptor::CppType()) {
GOOGLE_LOG(FATAL) << "Protocol Buffer map usage error:\n"
<< "MapKey::type MapKey is not initialized. "
<< "Call set methods to initialize MapKey.";
GOOGLE_ABSL_LOG(FATAL) << "Protocol Buffer map usage error:\n"
<< "MapKey::type MapKey is not initialized. "
<< "Call set methods to initialize MapKey.";
}
return type_;
}
@ -157,14 +158,14 @@ class PROTOBUF_EXPORT MapKey {
if (type_ != other.type_) {
// We could define a total order that handles this case, but
// there currently no need. So, for now, fail.
GOOGLE_LOG(FATAL) << "Unsupported: type mismatch";
GOOGLE_ABSL_LOG(FATAL) << "Unsupported: type mismatch";
}
switch (type()) {
case FieldDescriptor::CPPTYPE_DOUBLE:
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
GOOGLE_LOG(FATAL) << "Unsupported";
GOOGLE_ABSL_LOG(FATAL) << "Unsupported";
return false;
case FieldDescriptor::CPPTYPE_STRING:
return val_.string_value_.get() < other.val_.string_value_.get();
@ -185,14 +186,14 @@ class PROTOBUF_EXPORT MapKey {
bool operator==(const MapKey& other) const {
if (type_ != other.type_) {
// To be consistent with operator<, we don't allow this either.
GOOGLE_LOG(FATAL) << "Unsupported: type mismatch";
GOOGLE_ABSL_LOG(FATAL) << "Unsupported: type mismatch";
}
switch (type()) {
case FieldDescriptor::CPPTYPE_DOUBLE:
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
GOOGLE_LOG(FATAL) << "Unsupported";
GOOGLE_ABSL_LOG(FATAL) << "Unsupported";
break;
case FieldDescriptor::CPPTYPE_STRING:
return val_.string_value_.get() == other.val_.string_value_.get();
@ -207,7 +208,7 @@ class PROTOBUF_EXPORT MapKey {
case FieldDescriptor::CPPTYPE_BOOL:
return val_.bool_value_ == other.val_.bool_value_;
}
GOOGLE_LOG(FATAL) << "Can't get here.";
GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return false;
}
@ -218,7 +219,7 @@ class PROTOBUF_EXPORT MapKey {
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
GOOGLE_LOG(FATAL) << "Unsupported";
GOOGLE_ABSL_LOG(FATAL) << "Unsupported";
break;
case FieldDescriptor::CPPTYPE_STRING:
*val_.string_value_.get_mutable() = other.val_.string_value_.get();
@ -284,7 +285,7 @@ struct hash<::PROTOBUF_NAMESPACE_ID::MapKey> {
case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_FLOAT:
case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_ENUM:
case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_MESSAGE:
GOOGLE_LOG(FATAL) << "Unsupported";
GOOGLE_ABSL_LOG(FATAL) << "Unsupported";
break;
case ::PROTOBUF_NAMESPACE_ID::FieldDescriptor::CPPTYPE_STRING:
return hash<std::string>()(map_key.GetStringValue());
@ -308,7 +309,7 @@ struct hash<::PROTOBUF_NAMESPACE_ID::MapKey> {
return hash<bool>()(map_key.GetBoolValue());
}
}
GOOGLE_LOG(FATAL) << "Can't get here.";
GOOGLE_ABSL_LOG(FATAL) << "Can't get here.";
return 0;
}
bool operator()(const ::PROTOBUF_NAMESPACE_ID::MapKey& map_key1,
@ -351,7 +352,7 @@ class PROTOBUF_EXPORT MapFieldBase {
protected:
~MapFieldBase() { // "protected" stops users from deleting a `MapFieldBase *`
GOOGLE_DCHECK(repeated_field_ == nullptr);
GOOGLE_ABSL_DCHECK(repeated_field_ == nullptr);
}
void Destruct();
@ -427,7 +428,7 @@ class PROTOBUF_EXPORT MapFieldBase {
// MapFieldBase-derived object, and there is no synchronization going
// on between them, tsan will alert.
#if defined(__SANITIZE_THREAD__) || defined(THREAD_SANITIZER)
void ConstAccess() const { GOOGLE_CHECK_EQ(seq1_, seq2_); }
void ConstAccess() const { GOOGLE_ABSL_CHECK_EQ(seq1_, seq2_); }
void MutableAccess() {
if (seq1_ & 1) {
seq2_ = ++seq1_;
@ -767,7 +768,7 @@ class PROTOBUF_EXPORT MapValueConstRef {
FieldDescriptor::CppType type() const {
if (type_ == FieldDescriptor::CppType() || data_ == nullptr) {
GOOGLE_LOG(FATAL)
GOOGLE_ABSL_LOG(FATAL)
<< "Protocol Buffer map usage error:\n"
<< "MapValueConstRef::type MapValueConstRef is not initialized.";
}

@ -142,7 +142,7 @@ template <typename Key, typename T>
void TypeDefinedMapFieldBase<Key, T>::InitializeIterator(
MapIterator* map_iter) const {
map_iter->iter_ = new typename Map<Key, T>::const_iterator;
GOOGLE_CHECK(map_iter->iter_ != nullptr);
GOOGLE_ABSL_CHECK(map_iter->iter_ != nullptr);
}
template <typename Key, typename T>
@ -345,7 +345,7 @@ void MapField<Derived, Key, T, kKeyFieldType,
RepeatedPtrField<EntryType>* repeated_field =
reinterpret_cast<RepeatedPtrField<EntryType>*>(
this->MapFieldBase::repeated_field_);
GOOGLE_CHECK(this->MapFieldBase::repeated_field_ != nullptr);
GOOGLE_ABSL_CHECK(this->MapFieldBase::repeated_field_ != nullptr);
map->clear();
for (typename RepeatedPtrField<EntryType>::iterator it =
repeated_field->begin();

@ -193,7 +193,7 @@ struct MapEntryToMapField<
#ifndef NDEBUG
inline PROTOBUF_NOINLINE void MapFieldLiteNotDestructed(void* map_field_lite) {
bool proper_destruct = false;
GOOGLE_CHECK(proper_destruct) << map_field_lite;
GOOGLE_ABSL_CHECK(proper_destruct) << map_field_lite;
}
#endif

@ -31,7 +31,6 @@
#include <map>
#include <memory>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/map.h"
#include "google/protobuf/map_field_inl.h"
@ -39,6 +38,7 @@
#include "google/protobuf/repeated_field.h"
#include <gtest/gtest.h>
#include "absl/container/flat_hash_map.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/str_format.h"
#include "google/protobuf/arena_test_util.h"
#include "google/protobuf/map_test_util.h"

@ -44,6 +44,7 @@
#include <sstream>
#include <vector>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/testing/file.h"
#include "google/protobuf/descriptor.pb.h"
@ -399,7 +400,7 @@ TEST_F(MapImplTest, BeginIsFast) {
frog += counter++;
last_key =
static_cast<int>(frog) >= 0 ? static_cast<int>(frog) : last_key ^ 1;
GOOGLE_DCHECK_GE(last_key, 0);
GOOGLE_ABSL_DCHECK_GE(last_key, 0);
map[last_key] = last_key ^ 1;
}
std::vector<int64_t> times;
@ -407,7 +408,7 @@ TEST_F(MapImplTest, BeginIsFast) {
// just in case one iteration is fast compared to the granularity of
// our time keeping, we measure kChunkSize iterations per outer-loop iter.
const int kChunkSize = 1000;
GOOGLE_CHECK_EQ(kTestSize % kChunkSize, 0);
GOOGLE_ABSL_CHECK_EQ(kTestSize % kChunkSize, 0);
do {
const int64_t start = Now();
for (int i = 0; i < kChunkSize; i++) {
@ -419,12 +420,12 @@ TEST_F(MapImplTest, BeginIsFast) {
}
} while (!map.empty());
if (times.size() < .99 * kTestSize / kChunkSize) {
GOOGLE_LOG(WARNING) << "Now() isn't helping us measure time";
GOOGLE_ABSL_LOG(WARNING) << "Now() isn't helping us measure time";
return;
}
int64_t x0 = median(times.begin(), times.begin() + 9);
int64_t x1 = median(times.begin() + times.size() - 9, times.end());
GOOGLE_LOG(INFO) << "x0=" << x0 << ", x1=" << x1;
GOOGLE_ABSL_LOG(INFO) << "x0=" << x0 << ", x1=" << x1;
// x1 will greatly exceed x0 if the code we just executed took O(n^2) time.
// And we'll probably time out and never get here. So, this test is
// intentionally loose: we check that x0 and x1 are within a factor of 8.
@ -516,7 +517,7 @@ static void TestOldVersusNewIterator(int skip, Map<int, int>* m) {
}
if (it == m->end()) return;
const IteratorType old = it;
GOOGLE_LOG(INFO) << "skip=" << skip << ", old->first=" << old->first;
GOOGLE_ABSL_LOG(INFO) << "skip=" << skip << ", old->first=" << old->first;
const int target_size =
initial_size < 100 ? initial_size * 5 : initial_size * 5 / 4;
for (int i = 0; m->size() <= target_size; i++) {
@ -544,8 +545,8 @@ static void TestOldVersusNewIterator(int skip, Map<int, int>* m) {
// Create and test an n-element Map, with emphasis on iterator correctness.
static void StressTestIterators(int n) {
GOOGLE_LOG(INFO) << "StressTestIterators " << n;
GOOGLE_CHECK_GT(n, 0);
GOOGLE_ABSL_LOG(INFO) << "StressTestIterators " << n;
GOOGLE_ABSL_CHECK_GT(n, 0);
// Create a random-looking map of size n. Use non-negative integer keys.
Map<int, int> m;
uint32_t frog = 123987 + n;
@ -557,7 +558,7 @@ static void StressTestIterators(int n) {
frog += counter++;
last_key =
static_cast<int>(frog) >= 0 ? static_cast<int>(frog) : last_key ^ 1;
GOOGLE_DCHECK_GE(last_key, 0);
GOOGLE_ABSL_DCHECK_GE(last_key, 0);
m[last_key] = last_key ^ 1;
}
// Test it.
@ -3833,7 +3834,7 @@ TEST(MapSerializationTest, DeterministicSubmessage) {
UNITTEST::TestMaps t;
const std::string filename = "golden_message_maps";
std::string golden;
GOOGLE_CHECK_OK(File::GetContents(
GOOGLE_ABSL_CHECK_OK(File::GetContents(
TestUtil::GetTestDataPath("third_party/protobuf/testdata/" + filename),
&golden, true));
t.ParseFromString(golden);
@ -3875,7 +3876,7 @@ TEST(TextFormatMapTest, DynamicMessage) {
tester.SetMapFieldsViaReflection(message.get());
std::string expected_text;
GOOGLE_CHECK_OK(
GOOGLE_ABSL_CHECK_OK(
File::GetContents(TestUtil::GetTestDataPath("third_party/protobuf/"
"testdata/map_test_data.txt"),
&expected_text, true));
@ -3891,7 +3892,7 @@ TEST(TextFormatMapTest, Sorted) {
tester.SetMapFieldsViaReflection(&message);
std::string expected_text;
GOOGLE_CHECK_OK(
GOOGLE_ABSL_CHECK_OK(
File::GetContents(TestUtil::GetTestDataPath("third_party/protobuf/"
"testdata/map_test_data.txt"),
&expected_text, true));
@ -3911,12 +3912,12 @@ TEST(TextFormatMapTest, Sorted) {
TEST(TextFormatMapTest, ParseCorruptedString) {
std::string serialized_message;
GOOGLE_CHECK_OK(File::GetContents(
GOOGLE_ABSL_CHECK_OK(File::GetContents(
TestUtil::GetTestDataPath(
"third_party/protobuf/testdata/golden_message_maps"),
&serialized_message, true));
UNITTEST::TestMaps message;
GOOGLE_CHECK(message.ParseFromString(serialized_message));
GOOGLE_ABSL_CHECK(message.ParseFromString(serialized_message));
TestParseCorruptedString<UNITTEST::TestMaps, true>(message);
TestParseCorruptedString<UNITTEST::TestMaps, false>(message);
}
@ -3978,7 +3979,7 @@ TEST(TextFormatMapTest, NoDisableReflectionIterator) {
const Reflection* map_entry_reflection = iter->GetReflection();
const FieldDescriptor* value_field_desc = iter->GetDescriptor()->map_value();
map_entry_reflection->SetInt32(&(*iter), value_field_desc, 2);
GOOGLE_LOG(INFO) << iter->DebugString();
GOOGLE_ABSL_LOG(INFO) << iter->DebugString();
// In previous implementation, the new change won't be reflected in text
// format, because the previous iterator has been invalidated.

@ -31,7 +31,6 @@
#ifndef GOOGLE_PROTOBUF_MAP_TEST_UTIL_IMPL_H__
#define GOOGLE_PROTOBUF_MAP_TEST_UTIL_IMPL_H__
#include "google/protobuf/stubs/logging.h"
#include <gtest/gtest.h>

@ -37,10 +37,11 @@
#include <iostream>
#include <stack>
#include "google/protobuf/stubs/logging.h"
#include "absl/base/casts.h"
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/str_join.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/mutex.h"
@ -105,7 +106,7 @@ void Message::CopyFrom(const Message& from) {
if (class_to == nullptr || class_to != class_from) {
const Descriptor* descriptor = GetDescriptor();
GOOGLE_CHECK_EQ(from.GetDescriptor(), descriptor)
GOOGLE_ABSL_CHECK_EQ(from.GetDescriptor(), descriptor)
<< ": Tried to copy from a message with a different type. "
"to: "
<< descriptor->full_name()
@ -132,7 +133,7 @@ void Message::FailIfCopyFromDescendant(Message& to, const Message& from) {
bool same_message_owned_arena = to.GetOwningArena() == nullptr &&
arena != nullptr &&
arena == from.GetOwningArena();
GOOGLE_CHECK(!same_message_owned_arena && !internal::IsDescendant(to, from))
GOOGLE_ABSL_CHECK(!same_message_owned_arena && !internal::IsDescendant(to, from))
<< "Source of CopyFrom cannot be a descendant of the target.";
}
@ -157,9 +158,9 @@ std::string Message::InitializationErrorString() const {
}
void Message::CheckInitialized() const {
GOOGLE_CHECK(IsInitialized()) << "Message of type \"" << GetDescriptor()->full_name()
<< "\" is missing required fields: "
<< InitializationErrorString();
GOOGLE_ABSL_CHECK(IsInitialized())
<< "Message of type \"" << GetDescriptor()->full_name()
<< "\" is missing required fields: " << InitializationErrorString();
}
void Message::DiscardUnknownFields() {
@ -191,9 +192,9 @@ size_t Message::ByteSizeLong() const {
}
void Message::SetCachedSize(int /* size */) const {
GOOGLE_LOG(FATAL) << "Message class \"" << GetDescriptor()->full_name()
<< "\" implements neither SetCachedSize() nor ByteSize(). "
"Must implement one or the other.";
GOOGLE_ABSL_LOG(FATAL) << "Message class \"" << GetDescriptor()->full_name()
<< "\" implements neither SetCachedSize() nor ByteSize(). "
"Must implement one or the other.";
}
size_t Message::ComputeUnknownFieldsSize(
@ -226,7 +227,7 @@ namespace internal {
void* CreateSplitMessageGeneric(Arena* arena, const void* default_split,
size_t size, const void* message,
const void* default_message) {
GOOGLE_DCHECK_NE(message, default_message);
GOOGLE_ABSL_DCHECK_NE(message, default_message);
void* split =
(arena == nullptr) ? ::operator new(size) : arena->AllocateAligned(size);
memcpy(split, default_split, size);
@ -315,13 +316,13 @@ GeneratedMessageFactory* GeneratedMessageFactory::singleton() {
void GeneratedMessageFactory::RegisterFile(
const google::protobuf::internal::DescriptorTable* table) {
if (!files_.insert(table).second) {
GOOGLE_LOG(FATAL) << "File is already registered: " << table->filename;
GOOGLE_ABSL_LOG(FATAL) << "File is already registered: " << table->filename;
}
}
void GeneratedMessageFactory::RegisterType(const Descriptor* descriptor,
const Message* prototype) {
GOOGLE_DCHECK_EQ(descriptor->file()->pool(), DescriptorPool::generated_pool())
GOOGLE_ABSL_DCHECK_EQ(descriptor->file()->pool(), DescriptorPool::generated_pool())
<< "Tried to register a non-generated type with the generated "
"type registry.";
@ -330,7 +331,8 @@ void GeneratedMessageFactory::RegisterType(const Descriptor* descriptor,
// the mutex.
mutex_.AssertHeld();
if (!type_map_.try_emplace(descriptor, prototype).second) {
GOOGLE_LOG(DFATAL) << "Type is already registered: " << descriptor->full_name();
GOOGLE_ABSL_LOG(DFATAL) << "Type is already registered: "
<< descriptor->full_name();
}
}
@ -350,9 +352,9 @@ const Message* GeneratedMessageFactory::GetPrototype(const Descriptor* type) {
const internal::DescriptorTable* registration_data =
FindInFileMap(type->file()->name());
if (registration_data == nullptr) {
GOOGLE_LOG(DFATAL) << "File appears to be in generated pool but wasn't "
"registered: "
<< type->file()->name();
GOOGLE_ABSL_LOG(DFATAL) << "File appears to be in generated pool but wasn't "
"registered: "
<< type->file()->name();
return nullptr;
}
@ -368,8 +370,8 @@ const Message* GeneratedMessageFactory::GetPrototype(const Descriptor* type) {
}
if (result == nullptr) {
GOOGLE_LOG(DFATAL) << "Type appears to be in generated pool but wasn't "
<< "registered: " << type->full_name();
GOOGLE_ABSL_LOG(DFATAL) << "Type appears to be in generated pool but wasn't "
<< "registered: " << type->full_name();
}
return result;
@ -402,7 +404,7 @@ T* GetSingleton() {
const internal::RepeatedFieldAccessor* Reflection::RepeatedFieldAccessor(
const FieldDescriptor* field) const {
GOOGLE_CHECK(field->is_repeated());
GOOGLE_ABSL_CHECK(field->is_repeated());
switch (field->cpp_type()) {
#define HANDLE_PRIMITIVE_TYPE(TYPE, type) \
case FieldDescriptor::CPPTYPE_##TYPE: \
@ -430,7 +432,7 @@ const internal::RepeatedFieldAccessor* Reflection::RepeatedFieldAccessor(
return GetSingleton<internal::RepeatedPtrFieldMessageAccessor>();
}
}
GOOGLE_LOG(FATAL) << "Should not reach here.";
GOOGLE_ABSL_LOG(FATAL) << "Should not reach here.";
return nullptr;
}

@ -276,8 +276,8 @@ class PROTOBUF_EXPORT Message : public MessageLite {
// exact same class).
virtual void MergeFrom(const Message& from);
// Verifies that IsInitialized() returns true. GOOGLE_CHECK-fails otherwise, with
// a nice error message.
// Verifies that IsInitialized() returns true. GOOGLE_ABSL_CHECK-fails otherwise,
// with a nice error message.
void CheckInitialized() const;
// Slowly build a list of all required fields that are not set.
@ -941,7 +941,7 @@ class PROTOBUF_EXPORT Reflection final {
// take arbitrary integer values, and the legacy GetEnum() getter will
// dynamically create an EnumValueDescriptor for any integer value without
// one. If |false|, setting an unknown enum value via the integer-based
// setters results in undefined behavior (in practice, GOOGLE_DCHECK-fails).
// setters results in undefined behavior (in practice, GOOGLE_ABSL_DCHECK-fails).
//
// Generic code that uses reflection to handle messages with enum fields
// should check this flag before using the integer-based setter, and either
@ -1546,7 +1546,7 @@ const Type& Reflection::DefaultRaw(const FieldDescriptor* field) const {
uint32_t Reflection::GetOneofCase(
const Message& message, const OneofDescriptor* oneof_descriptor) const {
GOOGLE_DCHECK(!oneof_descriptor->is_synthetic());
GOOGLE_ABSL_DCHECK(!oneof_descriptor->is_synthetic());
return internal::GetConstRefAtOffset<uint32_t>(
message, schema_.GetOneofCaseOffset(oneof_descriptor));
}
@ -1558,20 +1558,20 @@ bool Reflection::HasOneofField(const Message& message,
}
const void* Reflection::GetSplitField(const Message* message) const {
GOOGLE_DCHECK(schema_.IsSplit());
GOOGLE_ABSL_DCHECK(schema_.IsSplit());
return *internal::GetConstPointerAtOffset<void*>(message,
schema_.SplitOffset());
}
void** Reflection::MutableSplitField(Message* message) const {
GOOGLE_DCHECK(schema_.IsSplit());
GOOGLE_ABSL_DCHECK(schema_.IsSplit());
return internal::GetPointerAtOffset<void*>(message, schema_.SplitOffset());
}
template <typename Type>
const Type& Reflection::GetRaw(const Message& message,
const FieldDescriptor* field) const {
GOOGLE_DCHECK(!schema_.InRealOneof(field) || HasOneofField(message, field))
GOOGLE_ABSL_DCHECK(!schema_.InRealOneof(field) || HasOneofField(message, field))
<< "Field = " << field->full_name();
if (schema_.IsSplit(field)) {
return *internal::GetConstPointerAtOffset<Type>(

@ -42,9 +42,10 @@
#include <string>
#include <utility>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/arena.h"
#include "absl/base/dynamic_annotations.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/cord.h"
#include "absl/strings/internal/resize_uninitialized.h"
#include "absl/strings/str_cat.h"
@ -83,15 +84,15 @@ void ByteSizeConsistencyError(size_t byte_size_before_serialization,
size_t byte_size_after_serialization,
size_t bytes_produced_by_serialization,
const MessageLite& message) {
GOOGLE_CHECK_EQ(byte_size_before_serialization, byte_size_after_serialization)
GOOGLE_ABSL_CHECK_EQ(byte_size_before_serialization, byte_size_after_serialization)
<< message.GetTypeName()
<< " was modified concurrently during serialization.";
GOOGLE_CHECK_EQ(bytes_produced_by_serialization, byte_size_before_serialization)
GOOGLE_ABSL_CHECK_EQ(bytes_produced_by_serialization, byte_size_before_serialization)
<< "Byte size calculation and serialization were inconsistent. This "
"may indicate a bug in protocol buffers or it may be caused by "
"concurrent modification of "
<< message.GetTypeName() << ".";
GOOGLE_LOG(FATAL) << "This shouldn't be called if all the sizes are equal.";
GOOGLE_ABSL_LOG(FATAL) << "This shouldn't be called if all the sizes are equal.";
}
std::string InitializationErrorMessage(absl::string_view action,
@ -120,7 +121,7 @@ inline bool CheckFieldPresence(const internal::ParseContext& ctx,
} // namespace
void MessageLite::LogInitializationErrorMessage() const {
GOOGLE_LOG(ERROR) << InitializationErrorMessage("parse", *this);
GOOGLE_ABSL_LOG(ERROR) << InitializationErrorMessage("parse", *this);
}
namespace internal {
@ -219,7 +220,7 @@ bool MessageLite::MergeFromImpl(io::CodedInputStream* input,
if (PROTOBUF_PREDICT_FALSE(!ptr)) return false;
ctx.BackUp(ptr);
if (!ctx.EndedAtEndOfStream()) {
GOOGLE_DCHECK_NE(ctx.LastTag(), 1); // We can't end on a pushed limit.
GOOGLE_ABSL_DCHECK_NE(ctx.LastTag(), 1); // We can't end on a pushed limit.
if (ctx.IsExceedingLimit(ptr)) return false;
input->SetLastTag(ctx.LastTag());
} else {
@ -332,14 +333,14 @@ inline uint8_t* SerializeToArrayImpl(const MessageLite& msg, uint8_t* target,
&ptr);
ptr = msg._InternalSerialize(ptr, &out);
out.Trim(ptr);
GOOGLE_DCHECK(!out.HadError() && stream.ByteCount() == size);
GOOGLE_ABSL_DCHECK(!out.HadError() && stream.ByteCount() == size);
return target + size;
} else {
io::EpsCopyOutputStream out(
target, size,
io::CodedOutputStream::IsDefaultSerializationDeterministic());
uint8_t* res = msg._InternalSerialize(target, &out);
GOOGLE_DCHECK(target + size == res);
GOOGLE_ABSL_DCHECK(target + size == res);
return res;
}
}
@ -351,7 +352,8 @@ uint8_t* MessageLite::SerializeWithCachedSizesToArray(uint8_t* target) const {
}
bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const {
GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this);
GOOGLE_ABSL_DCHECK(IsInitialized())
<< InitializationErrorMessage("serialize", *this);
return SerializePartialToCodedStream(output);
}
@ -359,8 +361,8 @@ bool MessageLite::SerializePartialToCodedStream(
io::CodedOutputStream* output) const {
const size_t size = ByteSizeLong(); // Force size to be cached.
if (size > INT_MAX) {
GOOGLE_LOG(ERROR) << GetTypeName()
<< " exceeded maximum protobuf size of 2GB: " << size;
GOOGLE_ABSL_LOG(ERROR) << GetTypeName()
<< " exceeded maximum protobuf size of 2GB: " << size;
return false;
}
@ -381,7 +383,8 @@ bool MessageLite::SerializePartialToCodedStream(
bool MessageLite::SerializeToZeroCopyStream(
io::ZeroCopyOutputStream* output) const {
GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this);
GOOGLE_ABSL_DCHECK(IsInitialized())
<< InitializationErrorMessage("serialize", *this);
return SerializePartialToZeroCopyStream(output);
}
@ -389,8 +392,8 @@ bool MessageLite::SerializePartialToZeroCopyStream(
io::ZeroCopyOutputStream* output) const {
const size_t size = ByteSizeLong(); // Force size to be cached.
if (size > INT_MAX) {
GOOGLE_LOG(ERROR) << GetTypeName()
<< " exceeded maximum protobuf size of 2GB: " << size;
GOOGLE_ABSL_LOG(ERROR) << GetTypeName()
<< " exceeded maximum protobuf size of 2GB: " << size;
return false;
}
@ -428,7 +431,8 @@ bool MessageLite::SerializePartialToOstream(std::ostream* output) const {
}
bool MessageLite::AppendToString(std::string* output) const {
GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this);
GOOGLE_ABSL_DCHECK(IsInitialized())
<< InitializationErrorMessage("serialize", *this);
return AppendPartialToString(output);
}
@ -436,8 +440,8 @@ bool MessageLite::AppendPartialToString(std::string* output) const {
size_t old_size = output->size();
size_t byte_size = ByteSizeLong();
if (byte_size > INT_MAX) {
GOOGLE_LOG(ERROR) << GetTypeName()
<< " exceeded maximum protobuf size of 2GB: " << byte_size;
GOOGLE_ABSL_LOG(ERROR) << GetTypeName()
<< " exceeded maximum protobuf size of 2GB: " << byte_size;
return false;
}
@ -460,15 +464,16 @@ bool MessageLite::SerializePartialToString(std::string* output) const {
}
bool MessageLite::SerializeToArray(void* data, int size) const {
GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this);
GOOGLE_ABSL_DCHECK(IsInitialized())
<< InitializationErrorMessage("serialize", *this);
return SerializePartialToArray(data, size);
}
bool MessageLite::SerializePartialToArray(void* data, int size) const {
const size_t byte_size = ByteSizeLong();
if (byte_size > INT_MAX) {
GOOGLE_LOG(ERROR) << GetTypeName()
<< " exceeded maximum protobuf size of 2GB: " << byte_size;
GOOGLE_ABSL_LOG(ERROR) << GetTypeName()
<< " exceeded maximum protobuf size of 2GB: " << byte_size;
return false;
}
if (size < static_cast<int64_t>(byte_size)) return false;

@ -45,10 +45,10 @@
#include <string>
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/port.h"
#include "absl/base/call_once.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/explicitly_constructed.h"
#include "google/protobuf/io/coded_stream.h"
@ -103,7 +103,7 @@ class GenericTypeHandler; // defined in repeated_field.h
// computed size to a cached size. Since we don't proceed with serialization
// if the total size was > INT_MAX, it is not important what this function
// returns for inputs > INT_MAX. However this case should not error or
// GOOGLE_CHECK-fail, because the full size_t resolution is still returned from
// GOOGLE_ABSL_CHECK-fail, because the full size_t resolution is still returned from
// ByteSizeLong() and checked against INT_MAX; we can catch the overflow
// there.
inline int ToCachedSize(size_t size) { return static_cast<int>(size); }
@ -118,11 +118,11 @@ inline size_t FromIntSize(int size) {
return static_cast<unsigned int>(size);
}
// For cases where a legacy function returns an integer size. We GOOGLE_DCHECK()
// For cases where a legacy function returns an integer size. We GOOGLE_ABSL_DCHECK()
// that the conversion will fit within an integer; if this is false then we
// are losing information.
inline int ToIntSize(size_t size) {
GOOGLE_DCHECK_LE(size, static_cast<size_t>(INT_MAX));
GOOGLE_ABSL_DCHECK_LE(size, static_cast<size_t>(INT_MAX));
return static_cast<int>(size);
}
@ -325,7 +325,7 @@ class PROTOBUF_EXPORT MessageLite {
// Write a protocol buffer of this message to the given output. Returns
// false on a write error. If the message is missing required fields,
// this may GOOGLE_CHECK-fail.
// this may GOOGLE_ABSL_CHECK-fail.
bool SerializeToCodedStream(io::CodedOutputStream* output) const;
// Like SerializeToCodedStream(), but allows missing required fields.
bool SerializePartialToCodedStream(io::CodedOutputStream* output) const;

@ -1270,7 +1270,7 @@ TEST(MESSAGE_TEST_NAME, TestEnumParsers) {
continue;
}
SCOPED_TRACE(value_desc->number());
GOOGLE_CHECK_NE(value_desc->number(), kInvalidValue)
GOOGLE_ABSL_CHECK_NE(value_desc->number(), kInvalidValue)
<< "Invalid value is a real label.";
auto encoded =
EncodeEnumValue(field->number(), value_desc->number(),
@ -1416,13 +1416,13 @@ class TestInputStream final : public io::ZeroCopyInputStream {
return true;
}
void BackUp(int) override { GOOGLE_CHECK(false); }
void BackUp(int) override { GOOGLE_ABSL_CHECK(false); }
bool Skip(int) override {
GOOGLE_CHECK(false);
GOOGLE_ABSL_CHECK(false);
return false;
}
int64_t ByteCount() const override {
GOOGLE_CHECK(false);
GOOGLE_ABSL_CHECK(false);
return 0;
}

@ -392,9 +392,9 @@ TEST(NoFieldPresenceTest, HasFieldOneofsTest) {
desc->FindFieldByName("oneof_nested_message");
const FieldDescriptor* desc_oneof_string =
desc->FindFieldByName("oneof_string");
GOOGLE_CHECK(desc_oneof_uint32 != nullptr);
GOOGLE_CHECK(desc_oneof_nested_message != nullptr);
GOOGLE_CHECK(desc_oneof_string != nullptr);
GOOGLE_ABSL_CHECK(desc_oneof_uint32 != nullptr);
GOOGLE_ABSL_CHECK(desc_oneof_nested_message != nullptr);
GOOGLE_ABSL_CHECK(desc_oneof_string != nullptr);
EXPECT_EQ(false, r->HasField(message, desc_oneof_uint32));
EXPECT_EQ(false, r->HasField(message, desc_oneof_nested_message));
@ -500,7 +500,7 @@ TEST(NoFieldPresenceTest, LazyMessageFieldHasBit) {
const Reflection* r = message.GetReflection();
const Descriptor* desc = message.GetDescriptor();
const FieldDescriptor* field = desc->FindFieldByName("optional_lazy_message");
GOOGLE_CHECK(field != nullptr);
GOOGLE_ABSL_CHECK(field != nullptr);
EXPECT_EQ(false, message.has_optional_lazy_message());
EXPECT_EQ(false, r->HasField(message, field));

@ -49,8 +49,8 @@ namespace {
// Only call if at start of tag.
bool ParseEndsInSlopRegion(const char* begin, int overrun, int depth) {
constexpr int kSlopBytes = EpsCopyInputStream::kSlopBytes;
GOOGLE_DCHECK_GE(overrun, 0);
GOOGLE_DCHECK_LE(overrun, kSlopBytes);
GOOGLE_ABSL_DCHECK_GE(overrun, 0);
GOOGLE_ABSL_DCHECK_LE(overrun, kSlopBytes);
auto ptr = begin + overrun;
auto end = begin + kSlopBytes;
while (ptr < end) {
@ -101,7 +101,7 @@ bool ParseEndsInSlopRegion(const char* begin, int overrun, int depth) {
const char* EpsCopyInputStream::NextBuffer(int overrun, int depth) {
if (next_chunk_ == nullptr) return nullptr; // We've reached end of stream.
if (next_chunk_ != buffer_) {
GOOGLE_DCHECK(size_ > kSlopBytes);
GOOGLE_ABSL_DCHECK(size_ > kSlopBytes);
// The chunk is large enough to be used directly
buffer_end_ = next_chunk_ + size_ - kSlopBytes;
auto res = next_chunk_;
@ -133,7 +133,7 @@ const char* EpsCopyInputStream::NextBuffer(int overrun, int depth) {
if (aliasing_ >= kNoDelta) aliasing_ = kOnPatch;
return buffer_;
}
GOOGLE_DCHECK(size_ == 0) << size_;
GOOGLE_ABSL_DCHECK(size_ == 0) << size_;
}
overall_limit_ = 0; // Next failed, no more needs for next
}
@ -154,7 +154,7 @@ const char* EpsCopyInputStream::NextBuffer(int overrun, int depth) {
}
const char* EpsCopyInputStream::Next() {
GOOGLE_DCHECK(limit_ > kSlopBytes);
GOOGLE_ABSL_DCHECK(limit_ > kSlopBytes);
auto p = NextBuffer(0 /* immaterial */, -1);
if (p == nullptr) {
limit_end_ = buffer_end_;
@ -171,25 +171,25 @@ std::pair<const char*, bool> EpsCopyInputStream::DoneFallback(int overrun,
int depth) {
// Did we exceeded the limit (parse error).
if (PROTOBUF_PREDICT_FALSE(overrun > limit_)) return {nullptr, true};
GOOGLE_DCHECK(overrun != limit_); // Guaranteed by caller.
GOOGLE_DCHECK(overrun < limit_); // Follows from above
GOOGLE_ABSL_DCHECK(overrun != limit_); // Guaranteed by caller.
GOOGLE_ABSL_DCHECK(overrun < limit_); // Follows from above
// TODO(gerbens) Instead of this dcheck we could just assign, and remove
// updating the limit_end from PopLimit, ie.
// limit_end_ = buffer_end_ + (std::min)(0, limit_);
// if (ptr < limit_end_) return {ptr, false};
GOOGLE_DCHECK(limit_end_ == buffer_end_ + (std::min)(0, limit_));
GOOGLE_ABSL_DCHECK(limit_end_ == buffer_end_ + (std::min)(0, limit_));
// At this point we know the following assertion holds.
GOOGLE_DCHECK_GT(limit_, 0);
GOOGLE_DCHECK(limit_end_ == buffer_end_); // because limit_ > 0
GOOGLE_ABSL_DCHECK_GT(limit_, 0);
GOOGLE_ABSL_DCHECK(limit_end_ == buffer_end_); // because limit_ > 0
const char* p;
do {
// We are past the end of buffer_end_, in the slop region.
GOOGLE_DCHECK_GE(overrun, 0);
GOOGLE_ABSL_DCHECK_GE(overrun, 0);
p = NextBuffer(overrun, depth);
if (p == nullptr) {
// We are at the end of the stream
if (PROTOBUF_PREDICT_FALSE(overrun != 0)) return {nullptr, true};
GOOGLE_DCHECK_GT(limit_, 0);
GOOGLE_ABSL_DCHECK_GT(limit_, 0);
limit_end_ = buffer_end_;
// Distinguish ending on a pushed limit or ending on end-of-stream.
SetEndOfStream();
@ -280,7 +280,7 @@ const char* ParseContext::ParseMessage(MessageLite* msg, const char* ptr) {
if (ptr == nullptr) return ptr;
auto old_depth = depth_;
ptr = msg->_InternalParse(ptr, this);
if (ptr != nullptr) GOOGLE_DCHECK_EQ(old_depth, depth_);
if (ptr != nullptr) GOOGLE_ABSL_DCHECK_EQ(old_depth, depth_);
depth_++;
if (!PopLimit(old)) return nullptr;
return ptr;
@ -618,7 +618,7 @@ const char* UnknownFieldParse(uint32_t tag, std::string* unknown,
// result = <multiple operations to calculate result>
// num_bits = ValueBarrier(num_bits, result);
// if (num_bits == 63) {
// GOOGLE_LOG(FATAL) << "Invalid num_bits value";
// GOOGLE_ABSL_LOG(FATAL) << "Invalid num_bits value";
// }
// ```
template <typename V1Type, typename V2Type>
@ -638,7 +638,7 @@ PROTOBUF_ALWAYS_INLINE inline V1Type ValueBarrier(V1Type value1) {
PROTOBUF_ALWAYS_INLINE inline uint64_t ExtractAndMergeTwoChunks(
uint64_t data, uint64_t first_byte) {
GOOGLE_DCHECK_LE(first_byte, 6);
GOOGLE_ABSL_DCHECK_LE(first_byte, 6);
uint64_t first = Ubfx7(data, first_byte * 8);
uint64_t second = Ubfx7(data, (first_byte + 1) * 8);
return ForceToRegister(first | (second << 7));

@ -578,7 +578,7 @@
#endif
// PROTOBUF_ASSUME(pred) tells the compiler that it can assume pred is true. To
// be safe, we also validate the assumption with a GOOGLE_DCHECK in unoptimized
// be safe, we also validate the assumption with a GOOGLE_ABSL_DCHECK in unoptimized
// builds. The macro does not do anything useful if the compiler does not
// support __builtin_assume.
#ifdef PROTOBUF_ASSUME
@ -586,10 +586,10 @@
#endif
#if __has_builtin(__builtin_assume)
#define PROTOBUF_ASSUME(pred) \
GOOGLE_DCHECK(pred); \
GOOGLE_ABSL_DCHECK(pred); \
__builtin_assume(pred)
#else
#define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred)
#define PROTOBUF_ASSUME(pred) GOOGLE_ABSL_DCHECK(pred)
#endif
// Specify memory alignment for structs, classes, etc.
@ -1020,14 +1020,14 @@ static_assert(PROTOBUF_CLANG_MIN(5, 0), "Protobuf only supports Clang 6.0 and ne
#define PROTOBUF_DEBUG false
#endif
// This `for` allows us to condition the `GOOGLE_LOG` on the define above, so that
// This `for` allows us to condition the `GOOGLE_ABSL_LOG` on the define above, so that
// code can write `PROTOBUF_DLOG(INFO) << ...;` and have it turned off when
// debug logging is off.
//
// This is a `for`, not and `if`, to avoid it accidentally chaining with an
// `else` below it.
#define PROTOBUF_DLOG(x) \
for (bool b = PROTOBUF_DEBUG; b; b = false) GOOGLE_LOG(x)
for (bool b = PROTOBUF_DEBUG; b; b = false) GOOGLE_ABSL_LOG(x)
#define PROTO2_IS_OSS true

@ -314,8 +314,8 @@ TEST(Proto3OptionalTest, Extensions) {
"protobuf_unittest.Proto3OptionalExtensions.ext_no_optional");
const FieldDescriptor* with_optional = p->FindExtensionByName(
"protobuf_unittest.Proto3OptionalExtensions.ext_with_optional");
GOOGLE_CHECK(no_optional);
GOOGLE_CHECK(with_optional);
GOOGLE_ABSL_CHECK(no_optional);
GOOGLE_ABSL_CHECK(with_optional);
EXPECT_FALSE(no_optional->has_optional_keyword());
EXPECT_TRUE(with_optional->has_optional_keyword());
@ -363,8 +363,8 @@ TEST(Proto3OptionalTest, OptionalFieldReflection) {
const google::protobuf::Reflection* r = msg.GetReflection();
const google::protobuf::FieldDescriptor* f = d->FindFieldByName("optional_int32");
const google::protobuf::OneofDescriptor* o = d->FindOneofByName("_optional_int32");
GOOGLE_CHECK(f);
GOOGLE_CHECK(o);
GOOGLE_ABSL_CHECK(f);
GOOGLE_ABSL_CHECK(o);
EXPECT_TRUE(o->is_synthetic());
EXPECT_FALSE(r->HasField(msg, f));

@ -234,7 +234,7 @@ class MapFieldAccessor final : public RandomAccessRepeatedFieldAccessor {
}
void Swap(Field* data, const internal::RepeatedFieldAccessor* other_mutator,
Field* other_data) const override {
GOOGLE_CHECK(this == other_mutator);
GOOGLE_ABSL_CHECK(this == other_mutator);
MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));
}
@ -278,7 +278,7 @@ class RepeatedFieldPrimitiveAccessor final : public RepeatedFieldWrapper<T> {
// Currently RepeatedFieldPrimitiveAccessor is the only implementation of
// RepeatedFieldAccessor for primitive types. As we are using singletons
// for these accessors, here "other_mutator" must be "this".
GOOGLE_CHECK(this == other_mutator);
GOOGLE_ABSL_CHECK(this == other_mutator);
MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));
}
@ -342,7 +342,7 @@ class RepeatedPtrFieldMessageAccessor final
RepeatedPtrFieldMessageAccessor() {}
void Swap(Field* data, const internal::RepeatedFieldAccessor* other_mutator,
Field* other_data) const override {
GOOGLE_CHECK(this == other_mutator);
GOOGLE_ABSL_CHECK(this == other_mutator);
MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));
}

@ -36,6 +36,7 @@
#include <string>
#include <vector>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/descriptor.h"
@ -57,7 +58,8 @@ static const Reflection* GetReflectionOrDie(const Message& m) {
const Descriptor* d = m.GetDescriptor();
const std::string& mtype = d ? d->name() : "unknown";
// RawMessage is one known type for which GetReflection() returns nullptr.
GOOGLE_LOG(FATAL) << "Message does not support reflection (type " << mtype << ").";
GOOGLE_ABSL_LOG(FATAL) << "Message does not support reflection (type " << mtype
<< ").";
}
return r;
}
@ -69,10 +71,10 @@ void ReflectionOps::Copy(const Message& from, Message* to) {
}
void ReflectionOps::Merge(const Message& from, Message* to) {
GOOGLE_CHECK_NE(&from, to);
GOOGLE_ABSL_CHECK_NE(&from, to);
const Descriptor* descriptor = from.GetDescriptor();
GOOGLE_CHECK_EQ(to->GetDescriptor(), descriptor)
GOOGLE_ABSL_CHECK_EQ(to->GetDescriptor(), descriptor)
<< "Tried to merge messages of different types "
<< "(merge " << descriptor->full_name() << " to "
<< to->GetDescriptor()->full_name() << ")";
@ -197,7 +199,7 @@ bool ReflectionOps::IsInitialized(const Message& message, bool check_fields,
if (const int field_count = descriptor->field_count()) {
const FieldDescriptor* begin = descriptor->field(0);
const FieldDescriptor* end = begin + field_count;
GOOGLE_DCHECK_EQ(descriptor->field(field_count - 1), end - 1);
GOOGLE_ABSL_DCHECK_EQ(descriptor->field(field_count - 1), end - 1);
if (check_fields) {
// Check required fields of this message.
@ -425,10 +427,10 @@ void ReflectionOps::FindInitializationErrors(const Message& message,
void GenericSwap(Message* lhs, Message* rhs) {
#ifndef PROTOBUF_FORCE_COPY_IN_SWAP
GOOGLE_DCHECK(Arena::InternalGetOwningArena(lhs) !=
Arena::InternalGetOwningArena(rhs));
GOOGLE_DCHECK(Arena::InternalGetOwningArena(lhs) != nullptr ||
Arena::InternalGetOwningArena(rhs) != nullptr);
GOOGLE_ABSL_DCHECK(Arena::InternalGetOwningArena(lhs) !=
Arena::InternalGetOwningArena(rhs));
GOOGLE_ABSL_DCHECK(Arena::InternalGetOwningArena(lhs) != nullptr ||
Arena::InternalGetOwningArena(rhs) != nullptr);
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
// At least one of these must have an arena, so make `rhs` point to it.
Arena* arena = Arena::InternalGetOwningArena(rhs);

@ -34,7 +34,6 @@
#include "google/protobuf/reflection_ops.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/descriptor.h"
#include <gtest/gtest.h>
#include "absl/strings/str_join.h"

@ -193,7 +193,7 @@ MapReflectionTester::MapReflectionTester(const Descriptor* base_descriptor)
map_int32_foreign_message_key_,
map_int32_foreign_message_val_};
for (const FieldDescriptor* fdesc : all_map_descriptors) {
GOOGLE_CHECK(fdesc->containing_type() != nullptr) << fdesc->name();
GOOGLE_ABSL_CHECK(fdesc->containing_type() != nullptr) << fdesc->name();
if (fdesc->name() == "key") {
EXPECT_EQ(fdesc->containing_type()->map_key(), fdesc);
} else {
@ -207,7 +207,7 @@ MapReflectionTester::MapReflectionTester(const Descriptor* base_descriptor)
const FieldDescriptor* MapReflectionTester::F(const std::string& name) {
const FieldDescriptor* result = nullptr;
result = base_descriptor_->FindFieldByName(name);
GOOGLE_CHECK(result != nullptr);
GOOGLE_ABSL_CHECK(result != nullptr);
return result;
}

@ -37,6 +37,7 @@
#include <algorithm>
#include <string>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/cord.h"

@ -52,9 +52,9 @@
#include <type_traits>
#include <utility>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/port.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/message_lite.h"
#include "google/protobuf/port.h"
#include "google/protobuf/repeated_ptr_field.h"
@ -308,7 +308,7 @@ class RepeatedField final {
// 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
// GOOGLE_DCHECK (see API docs for details).
// GOOGLE_ABSL_DCHECK (see API docs for details).
void UnsafeArenaSwap(RepeatedField* other);
static constexpr int kInitialSize = 0;
@ -355,7 +355,7 @@ class RepeatedField final {
// Returns a pointer to elements array.
// pre-condition: the array must have been allocated.
Element* elements() const {
GOOGLE_DCHECK_GT(total_size_, 0);
GOOGLE_ABSL_DCHECK_GT(total_size_, 0);
// Because of above pre-condition this cast is safe.
return unsafe_elements();
}
@ -614,19 +614,19 @@ inline int RepeatedField<Element>::Capacity() const {
template <typename Element>
inline void RepeatedField<Element>::AddAlreadyReserved(const Element& value) {
GOOGLE_DCHECK_LT(current_size_, total_size_);
GOOGLE_ABSL_DCHECK_LT(current_size_, total_size_);
elements()[ExchangeCurrentSize(current_size_ + 1)] = value;
}
template <typename Element>
inline Element* RepeatedField<Element>::AddAlreadyReserved() {
GOOGLE_DCHECK_LT(current_size_, total_size_);
GOOGLE_ABSL_DCHECK_LT(current_size_, total_size_);
return &elements()[ExchangeCurrentSize(current_size_ + 1)];
}
template <typename Element>
inline Element* RepeatedField<Element>::AddNAlreadyReserved(int elements) {
GOOGLE_DCHECK_GE(total_size_ - current_size_, elements)
GOOGLE_ABSL_DCHECK_GE(total_size_ - current_size_, elements)
<< total_size_ << ", " << current_size_;
// Warning: sometimes people call this when elements == 0 and
// total_size_ == 0. In this case the return pointer points to a zero size
@ -637,7 +637,7 @@ inline Element* RepeatedField<Element>::AddNAlreadyReserved(int elements) {
template <typename Element>
inline void RepeatedField<Element>::Resize(int new_size, const Element& value) {
GOOGLE_DCHECK_GE(new_size, 0);
GOOGLE_ABSL_DCHECK_GE(new_size, 0);
if (new_size > current_size_) {
Reserve(new_size);
std::fill(&elements()[ExchangeCurrentSize(new_size)], &elements()[new_size],
@ -649,36 +649,36 @@ inline void RepeatedField<Element>::Resize(int new_size, const Element& value) {
template <typename Element>
inline const Element& RepeatedField<Element>::Get(int index) const {
GOOGLE_DCHECK_GE(index, 0);
GOOGLE_DCHECK_LT(index, current_size_);
GOOGLE_ABSL_DCHECK_GE(index, 0);
GOOGLE_ABSL_DCHECK_LT(index, current_size_);
return elements()[index];
}
template <typename Element>
inline const Element& RepeatedField<Element>::at(int index) const {
GOOGLE_CHECK_GE(index, 0);
GOOGLE_CHECK_LT(index, current_size_);
GOOGLE_ABSL_CHECK_GE(index, 0);
GOOGLE_ABSL_CHECK_LT(index, current_size_);
return elements()[index];
}
template <typename Element>
inline Element& RepeatedField<Element>::at(int index) {
GOOGLE_CHECK_GE(index, 0);
GOOGLE_CHECK_LT(index, current_size_);
GOOGLE_ABSL_CHECK_GE(index, 0);
GOOGLE_ABSL_CHECK_LT(index, current_size_);
return elements()[index];
}
template <typename Element>
inline Element* RepeatedField<Element>::Mutable(int index) {
GOOGLE_DCHECK_GE(index, 0);
GOOGLE_DCHECK_LT(index, current_size_);
GOOGLE_ABSL_DCHECK_GE(index, 0);
GOOGLE_ABSL_DCHECK_LT(index, current_size_);
return &elements()[index];
}
template <typename Element>
inline void RepeatedField<Element>::Set(int index, const Element& value) {
GOOGLE_DCHECK_GE(index, 0);
GOOGLE_DCHECK_LT(index, current_size_);
GOOGLE_ABSL_DCHECK_GE(index, 0);
GOOGLE_ABSL_DCHECK_LT(index, current_size_);
elements()[index] = value;
}
@ -727,16 +727,16 @@ inline void RepeatedField<Element>::Add(Iter begin, Iter end) {
template <typename Element>
inline void RepeatedField<Element>::RemoveLast() {
GOOGLE_DCHECK_GT(current_size_, 0);
GOOGLE_ABSL_DCHECK_GT(current_size_, 0);
ExchangeCurrentSize(current_size_ - 1);
}
template <typename Element>
void RepeatedField<Element>::ExtractSubrange(int start, int num,
Element* elements) {
GOOGLE_DCHECK_GE(start, 0);
GOOGLE_DCHECK_GE(num, 0);
GOOGLE_DCHECK_LE(start + num, this->current_size_);
GOOGLE_ABSL_DCHECK_GE(start, 0);
GOOGLE_ABSL_DCHECK_GE(num, 0);
GOOGLE_ABSL_DCHECK_LE(start + num, this->current_size_);
// Save the values of the removed elements if requested.
if (elements != nullptr) {
@ -758,7 +758,7 @@ inline void RepeatedField<Element>::Clear() {
template <typename Element>
inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) {
GOOGLE_DCHECK_NE(&other, this);
GOOGLE_ABSL_DCHECK_NE(&other, this);
if (other.current_size_ != 0) {
int existing_size = size();
Reserve(existing_size + other.size());
@ -809,7 +809,7 @@ inline const Element* RepeatedField<Element>::data() const {
template <typename Element>
inline void RepeatedField<Element>::InternalSwap(RepeatedField* other) {
GOOGLE_DCHECK(this != other);
GOOGLE_ABSL_DCHECK(this != other);
// Swap all fields at once.
static_assert(std::is_standard_layout<RepeatedField<Element>>::value,
@ -842,7 +842,7 @@ void RepeatedField<Element>::Swap(RepeatedField* other) {
template <typename Element>
void RepeatedField<Element>::UnsafeArenaSwap(RepeatedField* other) {
if (this == other) return;
GOOGLE_DCHECK_EQ(GetOwningArena(), other->GetOwningArena());
GOOGLE_ABSL_DCHECK_EQ(GetOwningArena(), other->GetOwningArena());
InternalSwap(other);
}
@ -928,7 +928,7 @@ void RepeatedField<Element>::Reserve(int new_size) {
new_size = internal::CalculateReserveSize<Element, kRepHeaderSize>(
total_size_, new_size);
GOOGLE_DCHECK_LE(
GOOGLE_ABSL_DCHECK_LE(
static_cast<size_t>(new_size),
(std::numeric_limits<size_t>::max() - kRepHeaderSize) / sizeof(Element))
<< "Requested size is too large to fit into size_t.";
@ -972,7 +972,7 @@ void RepeatedField<Element>::Reserve(int new_size) {
template <typename Element>
inline void RepeatedField<Element>::Truncate(int new_size) {
GOOGLE_DCHECK_LE(new_size, current_size_);
GOOGLE_ABSL_DCHECK_LE(new_size, current_size_);
if (current_size_ > 0) {
ExchangeCurrentSize(new_size);
}

@ -166,7 +166,7 @@ TEST(RepeatedFieldReflectionTest, ExtensionFields) {
const FieldDescriptor* fd_repeated_int64_extension =
desc->file()->FindExtensionByName("repeated_int64_extension");
GOOGLE_CHECK(fd_repeated_int64_extension != nullptr);
GOOGLE_ABSL_CHECK(fd_repeated_int64_extension != nullptr);
const RepeatedField<int64_t>& rf_int64_extension =
refl->GetRepeatedField<int64_t>(extended_message,
@ -539,7 +539,7 @@ TEST(RepeatedFieldReflectionTest, RepeatedFieldRefForExtensionFields) {
const FieldDescriptor* fd_repeated_int64_extension =
desc->file()->FindExtensionByName("repeated_int64_extension");
GOOGLE_CHECK(fd_repeated_int64_extension != nullptr);
GOOGLE_ABSL_CHECK(fd_repeated_int64_extension != nullptr);
const RepeatedFieldRef<int64_t> rf_int64_extension =
refl->GetRepeatedFieldRef<int64_t>(extended_message,

@ -47,9 +47,9 @@
#include <type_traits>
#include <vector>
#include "google/protobuf/stubs/logging.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "absl/numeric/bits.h"
#include "absl/strings/cord.h"
#include "absl/strings/str_cat.h"
@ -195,7 +195,7 @@ TEST(RepeatedField, ArenaAllocationSizesMatchExpectedValues) {
// This is important to avoid a branch in the reallocation path.
// This is also important because allocating anything less would be wasting
// memory.
// If the allocation size is wrong, ReturnArrayMemory will GOOGLE_DCHECK.
// If the allocation size is wrong, ReturnArrayMemory will GOOGLE_ABSL_DCHECK.
CheckAllocationSizes<RepeatedField<bool>>(false);
CheckAllocationSizes<RepeatedField<uint8_t>>(false);
CheckAllocationSizes<RepeatedField<uint16_t>>(false);
@ -2143,7 +2143,7 @@ TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrSTLAlgorithms_lower_bound) {
std::lower_bound(proto_array_.pointer_begin(),
proto_array_.pointer_end(), &v, StringLessThan());
GOOGLE_CHECK(*it != nullptr);
GOOGLE_ABSL_CHECK(*it != nullptr);
EXPECT_EQ(**it, "n");
EXPECT_TRUE(it == proto_array_.pointer_begin() + 3);
@ -2154,7 +2154,7 @@ TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrSTLAlgorithms_lower_bound) {
const_proto_array_->pointer_begin(), const_proto_array_->pointer_end(),
&v, StringLessThan());
GOOGLE_CHECK(*it != nullptr);
GOOGLE_ABSL_CHECK(*it != nullptr);
EXPECT_EQ(**it, "n");
EXPECT_TRUE(it == const_proto_array_->pointer_begin() + 3);

@ -36,8 +36,8 @@
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/implicit_weak_message.h"
#include "google/protobuf/repeated_field.h"
#include "google/protobuf/port.h"
#include "google/protobuf/repeated_field.h"
// Must be included last.
#include "google/protobuf/port_def.inc"
@ -58,10 +58,10 @@ void** RepeatedPtrFieldBase::InternalExtend(int extend_amount) {
Arena* arena = GetOwningArena();
new_size = internal::CalculateReserveSize<void*, kRepHeaderSize>(total_size_,
new_size);
GOOGLE_CHECK_LE(static_cast<int64_t>(new_size),
static_cast<int64_t>(
(std::numeric_limits<size_t>::max() - kRepHeaderSize) /
sizeof(old_rep->elements[0])))
GOOGLE_ABSL_CHECK_LE(static_cast<int64_t>(new_size),
static_cast<int64_t>(
(std::numeric_limits<size_t>::max() - kRepHeaderSize) /
sizeof(old_rep->elements[0])))
<< "Requested size is too large to fit into size_t.";
size_t bytes = kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size;
if (arena == nullptr) {
@ -98,8 +98,8 @@ void RepeatedPtrFieldBase::Reserve(int new_size) {
}
void RepeatedPtrFieldBase::DestroyProtos() {
GOOGLE_DCHECK(rep_);
GOOGLE_DCHECK(arena_ == nullptr);
GOOGLE_ABSL_DCHECK(rep_);
GOOGLE_ABSL_DCHECK(arena_ == nullptr);
int n = rep_->allocated_size;
void* const* elements = rep_->elements;
for (int i = 0; i < n; i++) {

@ -58,9 +58,9 @@
#include <string>
#include <type_traits>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/port.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/message_lite.h"
#include "google/protobuf/port.h"
@ -187,22 +187,22 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
const typename TypeHandler::Type& at(int index) const {
GOOGLE_CHECK_GE(index, 0);
GOOGLE_CHECK_LT(index, current_size_);
GOOGLE_ABSL_CHECK_GE(index, 0);
GOOGLE_ABSL_CHECK_LT(index, current_size_);
return *cast<TypeHandler>(rep_->elements[index]);
}
template <typename TypeHandler>
typename TypeHandler::Type& at(int index) {
GOOGLE_CHECK_GE(index, 0);
GOOGLE_CHECK_LT(index, current_size_);
GOOGLE_ABSL_CHECK_GE(index, 0);
GOOGLE_ABSL_CHECK_LT(index, current_size_);
return *cast<TypeHandler>(rep_->elements[index]);
}
template <typename TypeHandler>
typename TypeHandler::Type* Mutable(int index) {
GOOGLE_DCHECK_GE(index, 0);
GOOGLE_DCHECK_LT(index, current_size_);
GOOGLE_ABSL_DCHECK_GE(index, 0);
GOOGLE_ABSL_DCHECK_LT(index, current_size_);
return cast<TypeHandler>(rep_->elements[index]);
}
@ -240,8 +240,8 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
void Delete(int index) {
GOOGLE_DCHECK_GE(index, 0);
GOOGLE_DCHECK_LT(index, current_size_);
GOOGLE_ABSL_DCHECK_GE(index, 0);
GOOGLE_ABSL_DCHECK_LT(index, current_size_);
TypeHandler::Delete(cast<TypeHandler>(rep_->elements[index]), arena_);
}
@ -270,8 +270,8 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
const typename TypeHandler::Type& Get(int index) const {
GOOGLE_DCHECK_GE(index, 0);
GOOGLE_DCHECK_LT(index, current_size_);
GOOGLE_ABSL_DCHECK_GE(index, 0);
GOOGLE_ABSL_DCHECK_LT(index, current_size_);
return *cast<TypeHandler>(rep_->elements[index]);
}
@ -284,7 +284,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
void Clear() {
const int n = current_size_;
GOOGLE_DCHECK_GE(n, 0);
GOOGLE_ABSL_DCHECK_GE(n, 0);
if (n > 0) {
ClearNonEmpty<TypeHandler>();
}
@ -298,14 +298,14 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
// binary. This calls a shared implementation with most of the logic,
// passing a function pointer to another type-specific piece of code that
// calls the object-allocate and merge handlers.
GOOGLE_DCHECK_NE(&other, this);
GOOGLE_ABSL_DCHECK_NE(&other, this);
if (other.current_size_ == 0) return;
MergeFromInternal(other,
&RepeatedPtrFieldBase::MergeFromInnerLoop<TypeHandler>);
}
inline void InternalSwap(RepeatedPtrFieldBase* rhs) {
GOOGLE_DCHECK(this != rhs);
GOOGLE_ABSL_DCHECK(this != rhs);
// Swap all fields at once.
auto temp = std::make_tuple(rhs->arena_, rhs->current_size_,
@ -346,7 +346,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
protected:
template <typename TypeHandler>
void RemoveLast() {
GOOGLE_DCHECK_GT(current_size_, 0);
GOOGLE_ABSL_DCHECK_GT(current_size_, 0);
ExchangeCurrentSize(current_size_ - 1);
TypeHandler::Clear(cast<TypeHandler>(rep_->elements[current_size_]));
}
@ -481,7 +481,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
// arena.
template <typename TypeHandler>
typename TypeHandler::Type* UnsafeArenaReleaseLast() {
GOOGLE_DCHECK_GT(current_size_, 0);
GOOGLE_ABSL_DCHECK_GT(current_size_, 0);
ExchangeCurrentSize(current_size_ - 1);
typename TypeHandler::Type* result =
cast<TypeHandler>(rep_->elements[current_size_]);
@ -500,9 +500,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
void AddCleared(typename TypeHandler::Type* value) {
GOOGLE_DCHECK(GetOwningArena() == nullptr) << "AddCleared() can only be used on a "
"RepeatedPtrField not on an arena.";
GOOGLE_DCHECK(TypeHandler::GetOwningArena(value) == nullptr)
GOOGLE_ABSL_DCHECK(GetOwningArena() == nullptr)
<< "AddCleared() can only be used on a "
"RepeatedPtrField not on an arena.";
GOOGLE_ABSL_DCHECK(TypeHandler::GetOwningArena(value) == nullptr)
<< "AddCleared() can only accept values not on an arena.";
if (!rep_ || rep_->allocated_size == total_size_) {
Reserve(total_size_ + 1);
@ -512,12 +513,12 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
PROTOBUF_NODISCARD typename TypeHandler::Type* ReleaseCleared() {
GOOGLE_DCHECK(GetOwningArena() == nullptr)
GOOGLE_ABSL_DCHECK(GetOwningArena() == nullptr)
<< "ReleaseCleared() can only be used on a RepeatedPtrField not on "
<< "an arena.";
GOOGLE_DCHECK(GetOwningArena() == nullptr);
GOOGLE_DCHECK(rep_ != nullptr);
GOOGLE_DCHECK_GT(rep_->allocated_size, current_size_);
GOOGLE_ABSL_DCHECK(GetOwningArena() == nullptr);
GOOGLE_ABSL_DCHECK(rep_ != nullptr);
GOOGLE_ABSL_DCHECK_GT(rep_->allocated_size, current_size_);
return cast<TypeHandler>(rep_->elements[--rep_->allocated_size]);
}
@ -609,10 +610,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
typename TypeHandler::Type* ReleaseLastInternal(std::false_type) {
// ReleaseLast() for types that *do not* implement merge/copy behavior --
// this is the same as UnsafeArenaReleaseLast(). Note that we GOOGLE_DCHECK-fail if
// we're on an arena, since the user really should implement the copy
// operation in this case.
GOOGLE_DCHECK(GetOwningArena() == nullptr)
// this is the same as UnsafeArenaReleaseLast(). Note that we
// GOOGLE_ABSL_DCHECK-fail if we're on an arena, since the user really should
// implement the copy operation in this case.
GOOGLE_ABSL_DCHECK(GetOwningArena() == nullptr)
<< "ReleaseLast() called on a RepeatedPtrField that is on an arena, "
<< "with a type that does not implement MergeFrom. This is unsafe; "
<< "please implement MergeFrom for your type.";
@ -622,10 +623,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
template <typename TypeHandler>
PROTOBUF_NOINLINE void SwapFallback(RepeatedPtrFieldBase* other) {
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
GOOGLE_DCHECK(GetOwningArena() == nullptr ||
other->GetOwningArena() != GetOwningArena());
GOOGLE_ABSL_DCHECK(GetOwningArena() == nullptr ||
other->GetOwningArena() != GetOwningArena());
#else // PROTOBUF_FORCE_COPY_IN_SWAP
GOOGLE_DCHECK(other->GetOwningArena() != GetOwningArena());
GOOGLE_ABSL_DCHECK(other->GetOwningArena() != GetOwningArena());
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
// Copy semantics in this case. We try to improve efficiency by placing the
@ -699,8 +700,9 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
const int n = current_size_;
void* const* elements = rep_->elements;
int i = 0;
GOOGLE_DCHECK_GT(n,
0); // do/while loop to avoid initial test because we know n > 0
GOOGLE_ABSL_DCHECK_GT(
n,
0); // do/while loop to avoid initial test because we know n > 0
do {
TypeHandler::Clear(cast<TypeHandler>(elements[i++]));
} while (i < n);
@ -996,7 +998,7 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase {
// Swaps entire contents with "other". Caller should guarantee that either
// both fields are on the same arena or both are on the heap. Swapping between
// different arenas with this function is disallowed and is caught via
// GOOGLE_DCHECK.
// GOOGLE_ABSL_DCHECK.
void UnsafeArenaSwap(RepeatedPtrField* other);
// Swaps two elements.
@ -1137,14 +1139,14 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase {
// this method.
//
// This method cannot be called when either the repeated field or |value| is
// on an arena; both cases will trigger a GOOGLE_DCHECK-failure.
// on an arena; both cases will trigger a GOOGLE_ABSL_DCHECK-failure.
void AddCleared(Element* value);
// Removes and returns a single element from the cleared pool, passing
// ownership to the caller. The element is guaranteed to be cleared.
// Requires: ClearedCount() > 0
//
// This method cannot be called when the repeated field is on an arena; doing
// so will trigger a GOOGLE_DCHECK-failure.
// so will trigger a GOOGLE_ABSL_DCHECK-failure.
PROTOBUF_NODISCARD Element* ReleaseCleared();
#endif // !PROTOBUF_FUTURE_REMOVE_CLEARED_API
@ -1353,9 +1355,9 @@ inline void RepeatedPtrField<Element>::RemoveLast() {
template <typename Element>
inline void RepeatedPtrField<Element>::DeleteSubrange(int start, int num) {
GOOGLE_DCHECK_GE(start, 0);
GOOGLE_DCHECK_GE(num, 0);
GOOGLE_DCHECK_LE(start + num, size());
GOOGLE_ABSL_DCHECK_GE(start, 0);
GOOGLE_ABSL_DCHECK_GE(num, 0);
GOOGLE_ABSL_DCHECK_LE(start + num, size());
for (int i = 0; i < num; ++i) {
RepeatedPtrFieldBase::Delete<TypeHandler>(start + i);
}
@ -1375,13 +1377,13 @@ inline void RepeatedPtrField<Element>::ExtractSubrange(int start, int num,
template <typename Element>
inline void RepeatedPtrField<Element>::ExtractSubrangeInternal(
int start, int num, Element** elements, std::true_type) {
GOOGLE_DCHECK_GE(start, 0);
GOOGLE_DCHECK_GE(num, 0);
GOOGLE_DCHECK_LE(start + num, size());
GOOGLE_ABSL_DCHECK_GE(start, 0);
GOOGLE_ABSL_DCHECK_GE(num, 0);
GOOGLE_ABSL_DCHECK_LE(start + num, size());
if (num == 0) return;
GOOGLE_DCHECK_NE(elements, nullptr)
GOOGLE_ABSL_DCHECK_NE(elements, nullptr)
<< "Releasing elements without transferring ownership is an unsafe "
"operation. Use UnsafeArenaExtractSubrange.";
if (elements == nullptr) {
@ -1425,9 +1427,9 @@ inline void RepeatedPtrField<Element>::ExtractSubrangeInternal(
int start, int num, Element** elements, std::false_type) {
// This case is identical to UnsafeArenaExtractSubrange(). However, since
// ExtractSubrange() must return heap-allocated objects by contract, and we
// cannot fulfill this contract if we are an on arena, we must GOOGLE_DCHECK() that
// we are not on an arena.
GOOGLE_DCHECK(GetOwningArena() == nullptr)
// cannot fulfill this contract if we are an on arena, we must GOOGLE_ABSL_DCHECK()
// that we are not on an arena.
GOOGLE_ABSL_DCHECK(GetOwningArena() == nullptr)
<< "ExtractSubrange() when arena is non-nullptr is only supported when "
<< "the Element type supplies a MergeFrom() operation to make copies.";
UnsafeArenaExtractSubrange(start, num, elements);
@ -1436,9 +1438,9 @@ inline void RepeatedPtrField<Element>::ExtractSubrangeInternal(
template <typename Element>
inline void RepeatedPtrField<Element>::UnsafeArenaExtractSubrange(
int start, int num, Element** elements) {
GOOGLE_DCHECK_GE(start, 0);
GOOGLE_DCHECK_GE(num, 0);
GOOGLE_DCHECK_LE(start + num, size());
GOOGLE_ABSL_DCHECK_GE(start, 0);
GOOGLE_ABSL_DCHECK_GE(num, 0);
GOOGLE_ABSL_DCHECK_LE(start + num, size());
if (num > 0) {
// Save the values of the removed elements if requested.
@ -1509,7 +1511,7 @@ template <typename Element>
inline void RepeatedPtrField<Element>::UnsafeArenaSwap(
RepeatedPtrField* other) {
if (this == other) return;
GOOGLE_DCHECK_EQ(GetOwningArena(), other->GetOwningArena());
GOOGLE_ABSL_DCHECK_EQ(GetOwningArena(), other->GetOwningArena());
RepeatedPtrFieldBase::InternalSwap(other);
}

@ -185,7 +185,7 @@ inline const FieldDescriptor* TestUtil::ReflectionTester::F(
} else {
result = base_descriptor_->FindFieldByName(name);
}
GOOGLE_CHECK(result != nullptr);
GOOGLE_ABSL_CHECK(result != nullptr);
return result;
}

@ -37,8 +37,8 @@
// within an enclosing namespace and requires header files to be included
// out of this file.
#include "google/protobuf/stubs/logging.h"
#include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/message.h"
@ -1113,7 +1113,7 @@ inline void TestUtil::SetOneofFields(UNITTEST::TestAllExtensions* message) {
inline void TestUtil::SetAllFieldsAndExtensions(
UNITTEST::TestFieldOrderings* message) {
GOOGLE_CHECK(message);
GOOGLE_ABSL_CHECK(message);
message->set_my_int(1);
message->set_my_string("foo");
message->set_my_float(1.0);

@ -50,7 +50,7 @@ inline std::string TranslatePathToOpensource(absl::string_view google3_path) {
constexpr absl::string_view net_proto2 = "net/proto2/";
constexpr absl::string_view third_party_protobuf = "third_party/protobuf/";
if (!absl::ConsumePrefix(&google3_path, net_proto2)) {
GOOGLE_CHECK(absl::ConsumePrefix(&google3_path, third_party_protobuf))
GOOGLE_ABSL_CHECK(absl::ConsumePrefix(&google3_path, third_party_protobuf))
<< google3_path;
}
@ -93,7 +93,7 @@ class BoundedArrayInputStream : public io::ZeroCopyInputStream {
~BoundedArrayInputStream() override {}
bool Next(const void** data, int* size) override {
GOOGLE_CHECK_LT(stream_.ByteCount(), bound_);
GOOGLE_ABSL_CHECK_LT(stream_.ByteCount(), bound_);
return stream_.Next(data, size);
}
void BackUp(int count) override { stream_.BackUp(count); }

@ -34,7 +34,6 @@
#include "google/protobuf/test_util_lite.h"
#include "google/protobuf/stubs/logging.h"
#include <gtest/gtest.h>
#include "absl/strings/string_view.h"

@ -206,11 +206,11 @@ void CheckFieldIndex(const FieldDescriptor* field, int index) {
}
if (field->is_repeated() && index == -1) {
GOOGLE_LOG(DFATAL) << "Index must be in range of repeated field values. "
<< "Field: " << field->name();
GOOGLE_ABSL_LOG(DFATAL) << "Index must be in range of repeated field values. "
<< "Field: " << field->name();
} else if (!field->is_repeated() && index != -1) {
GOOGLE_LOG(DFATAL) << "Index must be -1 for singular fields."
<< "Field: " << field->name();
GOOGLE_ABSL_LOG(DFATAL) << "Index must be -1 for singular fields."
<< "Field: " << field->name();
}
}
@ -346,7 +346,7 @@ class TextFormat::Parser::ParserImpl {
// Parses the ASCII representation specified in input and saves the
// information into the output pointer (a Message). Returns
// false if an error occurs (an error will also be logged to
// GOOGLE_LOG(ERROR)).
// GOOGLE_ABSL_LOG(ERROR)).
bool Parse(Message* output) {
// Consume fields until we cannot do so anymore.
while (true) {
@ -354,7 +354,7 @@ class TextFormat::Parser::ParserImpl {
// Ensures recursion limit properly unwinded, but only for success
// cases. This implicitly avoids the check when `Parse` returns false
// via `DO(...)`.
GOOGLE_DCHECK(had_errors_ || recursion_limit_ == initial_recursion_limit_)
GOOGLE_ABSL_DCHECK(had_errors_ || recursion_limit_ == initial_recursion_limit_)
<< "Recursion limit at end of parse should be "
<< initial_recursion_limit_ << ", but was " << recursion_limit_
<< ". Difference of " << initial_recursion_limit_ - recursion_limit_
@ -381,12 +381,12 @@ class TextFormat::Parser::ParserImpl {
had_errors_ = true;
if (error_collector_ == nullptr) {
if (line >= 0) {
GOOGLE_LOG(ERROR) << "Error parsing text-format "
<< root_message_type_->full_name() << ": " << (line + 1)
<< ":" << (col + 1) << ": " << message;
GOOGLE_ABSL_LOG(ERROR) << "Error parsing text-format "
<< root_message_type_->full_name() << ": " << (line + 1)
<< ":" << (col + 1) << ": " << message;
} else {
GOOGLE_LOG(ERROR) << "Error parsing text-format "
<< root_message_type_->full_name() << ": " << message;
GOOGLE_ABSL_LOG(ERROR) << "Error parsing text-format "
<< root_message_type_->full_name() << ": " << message;
}
} else {
error_collector_->AddError(line, col, message);
@ -396,12 +396,12 @@ class TextFormat::Parser::ParserImpl {
void ReportWarning(int line, int col, const std::string& message) {
if (error_collector_ == nullptr) {
if (line >= 0) {
GOOGLE_LOG(WARNING) << "Warning parsing text-format "
<< root_message_type_->full_name() << ": " << (line + 1)
<< ":" << (col + 1) << ": " << message;
GOOGLE_ABSL_LOG(WARNING) << "Warning parsing text-format "
<< root_message_type_->full_name() << ": "
<< (line + 1) << ":" << (col + 1) << ": " << message;
} else {
GOOGLE_LOG(WARNING) << "Warning parsing text-format "
<< root_message_type_->full_name() << ": " << message;
GOOGLE_ABSL_LOG(WARNING) << "Warning parsing text-format "
<< root_message_type_->full_name() << ": " << message;
}
} else {
error_collector_->AddWarning(line, col, message);
@ -591,7 +591,8 @@ class TextFormat::Parser::ParserImpl {
// Skips unknown or reserved fields.
if (field == nullptr) {
GOOGLE_CHECK(allow_unknown_field_ || allow_unknown_extension_ || reserved_field);
GOOGLE_ABSL_CHECK(allow_unknown_field_ || allow_unknown_extension_ ||
reserved_field);
// Try to guess the type of this field.
// If this field is not a message, there should be a ":" between the
@ -925,7 +926,7 @@ class TextFormat::Parser::ParserImpl {
case FieldDescriptor::CPPTYPE_MESSAGE: {
// We should never get here. Put here instead of a default
// so that if new types are added, we get a nice compiler warning.
GOOGLE_LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE";
GOOGLE_ABSL_LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE";
break;
}
}
@ -1429,7 +1430,7 @@ class TextFormat::Printer::TextGenerator
// level is zero.
void Outdent() override {
if (indent_level_ == 0 || indent_level_ < initial_indent_level_) {
GOOGLE_LOG(DFATAL) << " Outdent() without matching Indent().";
GOOGLE_ABSL_LOG(DFATAL) << " Outdent() without matching Indent().";
return;
}
@ -1523,7 +1524,7 @@ class TextFormat::Printer::TextGenerator
if (indent_level_ == 0) {
return;
}
GOOGLE_DCHECK(!failed_);
GOOGLE_ABSL_DCHECK(!failed_);
int size = GetCurrentIndentationSize();
while (size > buffer_size_) {
@ -2102,7 +2103,7 @@ bool TextFormat::Printer::RegisterMessagePrinter(
bool TextFormat::Printer::PrintToString(const Message& message,
std::string* output) const {
GOOGLE_DCHECK(output) << "output specified is nullptr";
GOOGLE_ABSL_DCHECK(output) << "output specified is nullptr";
output->clear();
io::StringOutputStream output_stream(output);
@ -2112,7 +2113,7 @@ bool TextFormat::Printer::PrintToString(const Message& message,
bool TextFormat::Printer::PrintUnknownFieldsToString(
const UnknownFieldSet& unknown_fields, std::string* output) const {
GOOGLE_DCHECK(output) << "output specified is nullptr";
GOOGLE_ABSL_DCHECK(output) << "output specified is nullptr";
output->clear();
io::StringOutputStream output_stream(output);
@ -2195,8 +2196,8 @@ bool TextFormat::Printer::PrintAny(const Message& message,
finder_ ? finder_->FindAnyType(message, url_prefix, full_type_name)
: DefaultFinderFindAnyType(message, url_prefix, full_type_name);
if (value_descriptor == nullptr) {
GOOGLE_LOG(WARNING) << "Can't print proto content: proto type " << type_url
<< " not found";
GOOGLE_ABSL_LOG(WARNING) << "Can't print proto content: proto type " << type_url
<< " not found";
return false;
}
DynamicMessageFactory factory;
@ -2204,7 +2205,7 @@ bool TextFormat::Printer::PrintAny(const Message& message,
factory.GetPrototype(value_descriptor)->New());
std::string serialized_value = reflection->GetString(message, value_field);
if (!value_message->ParseFromString(serialized_value)) {
GOOGLE_LOG(WARNING) << type_url << ": failed to parse contents";
GOOGLE_ABSL_LOG(WARNING) << type_url << ": failed to parse contents";
return false;
}
generator->PrintLiteral("[");
@ -2281,7 +2282,7 @@ void TextFormat::Printer::PrintFieldValueToString(const Message& message,
const FieldDescriptor* field,
int index,
std::string* output) const {
GOOGLE_DCHECK(output) << "output specified is nullptr";
GOOGLE_ABSL_DCHECK(output) << "output specified is nullptr";
output->clear();
io::StringOutputStream output_stream(output);
@ -2329,7 +2330,7 @@ class MapEntryMessageComparator {
return first < second;
}
default:
GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
GOOGLE_ABSL_LOG(DFATAL) << "Invalid key for map field.";
return true;
}
}
@ -2400,7 +2401,7 @@ void MapFieldPrinterHelper::CopyKey(const MapKey& key, Message* message,
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_ENUM:
case FieldDescriptor::CPPTYPE_MESSAGE:
GOOGLE_LOG(ERROR) << "Not supported.";
GOOGLE_ABSL_LOG(ERROR) << "Not supported.";
break;
case FieldDescriptor::CPPTYPE_STRING:
reflection->SetString(message, field_desc, key.GetStringValue());
@ -2575,7 +2576,7 @@ void TextFormat::Printer::PrintFieldValue(const Message& message,
const FieldDescriptor* field,
int index,
BaseTextGenerator* generator) const {
GOOGLE_DCHECK(field->is_repeated() || (index == -1))
GOOGLE_ABSL_DCHECK(field->is_repeated() || (index == -1))
<< "Index must be -1 for non-repeated fields";
const FastFieldValuePrinter* printer = GetFieldPrinter(field);
@ -2627,7 +2628,7 @@ void TextFormat::Printer::PrintFieldValue(const Message& message,
if (field->type() == FieldDescriptor::TYPE_STRING) {
printer->PrintString(*value_to_print, generator);
} else {
GOOGLE_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES);
GOOGLE_ABSL_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES);
printer->PrintBytes(*value_to_print, generator);
}
break;

@ -42,13 +42,13 @@
#include <memory>
#include <string>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/testing/file.h"
#include "google/protobuf/testing/file.h"
#include "google/protobuf/any.pb.h"
#include <gmock/gmock.h>
#include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
@ -91,7 +91,7 @@ const std::string kEscapeTestStringEscaped =
class TextFormatTest : public testing::Test {
public:
static void SetUpTestSuite() {
GOOGLE_CHECK_OK(File::GetContents(
GOOGLE_ABSL_CHECK_OK(File::GetContents(
TestUtil::GetTestDataPath(
"third_party/protobuf/"
"testdata/text_format_unittest_data_oneof_implemented.txt"),
@ -113,7 +113,7 @@ std::string TextFormatTest::static_proto_text_format_;
class TextFormatExtensionsTest : public testing::Test {
public:
static void SetUpTestSuite() {
GOOGLE_CHECK_OK(File::GetContents(
GOOGLE_ABSL_CHECK_OK(File::GetContents(
TestUtil::GetTestDataPath("third_party/protobuf/testdata/"
"text_format_unittest_extensions_data.txt"),
&static_proto_text_format_, true));

@ -61,7 +61,7 @@ const UnknownFieldSet& UnknownFieldSet::default_instance() {
}
void UnknownFieldSet::ClearFallback() {
GOOGLE_DCHECK(!fields_.empty());
GOOGLE_ABSL_DCHECK(!fields_.empty());
int n = fields_.size();
do {
(fields_)[--n].Delete();
@ -289,7 +289,7 @@ void UnknownField::DeepCopy(const UnknownField& other) {
uint8_t* UnknownField::InternalSerializeLengthDelimitedNoTag(
uint8_t* target, io::EpsCopyOutputStream* stream) const {
GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());
GOOGLE_ABSL_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());
const std::string& data = *data_.length_delimited_.string_value;
target = io::CodedOutputStream::WriteVarint32ToArray(data.size(), target);
target = stream->WriteRaw(data.data(), data.size(), target);

@ -45,8 +45,8 @@
#include <vector>
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/port.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
#include "google/protobuf/message_lite.h"
@ -393,7 +393,7 @@ bool UnknownFieldSet::MergeFromMessage(const MessageType& message) {
inline size_t UnknownField::GetLengthDelimitedSize() const {
GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());
GOOGLE_ABSL_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());
return data_.length_delimited_.string_value->size();
}

@ -42,7 +42,6 @@
#include "google/protobuf/stubs/callback.h"
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/stubs/logging.h"
#include <gmock/gmock.h>
#include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h>

@ -38,6 +38,7 @@
#include <string>
#include <vector>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/cord.h"
#include "google/protobuf/descriptor.h"
@ -401,7 +402,7 @@ bool WireFormat::ParseAndMergeMessageSetField(uint32_t field_number,
field->type() != FieldDescriptor::TYPE_MESSAGE) {
// This shouldn't happen as we only allow optional message extensions to
// MessageSet.
GOOGLE_LOG(ERROR) << "Extensions of MessageSets must be optional messages.";
GOOGLE_ABSL_LOG(ERROR) << "Extensions of MessageSets must be optional messages.";
return false;
} else {
Message* sub_message = message_reflection->MutableMessage(
@ -789,8 +790,8 @@ const char* WireFormat::_InternalParse(Message* msg, const char* ptr,
internal::ParseContext* ctx) {
const Descriptor* descriptor = msg->GetDescriptor();
const Reflection* reflection = msg->GetReflection();
GOOGLE_DCHECK(descriptor);
GOOGLE_DCHECK(reflection);
GOOGLE_ABSL_DCHECK(descriptor);
GOOGLE_ABSL_DCHECK(reflection);
if (descriptor->options().message_set_wire_format()) {
MessageSetParser message_set{msg, descriptor, reflection};
return message_set.ParseMessageSet(ptr, ctx);
@ -889,7 +890,7 @@ const char* WireFormat::_InternalParseAndMergeField(
case FieldDescriptor::TYPE_GROUP:
case FieldDescriptor::TYPE_MESSAGE:
case FieldDescriptor::TYPE_BYTES:
GOOGLE_LOG(FATAL) << "Can't reach";
GOOGLE_ABSL_LOG(FATAL) << "Can't reach";
return nullptr;
}
} else {
@ -1080,7 +1081,7 @@ uint8_t* SerializeMapKeyWithCachedSizes(const FieldDescriptor* field,
case FieldDescriptor::TYPE_MESSAGE:
case FieldDescriptor::TYPE_BYTES:
case FieldDescriptor::TYPE_ENUM:
GOOGLE_LOG(FATAL) << "Unsupported";
GOOGLE_ABSL_LOG(FATAL) << "Unsupported";
break;
#define CASE_TYPE(FieldType, CamelFieldType, CamelCppType) \
case FieldDescriptor::TYPE_##FieldType: \
@ -1169,7 +1170,7 @@ class MapKeySorter {
class MapKeyComparator {
public:
bool operator()(const MapKey& a, const MapKey& b) const {
GOOGLE_DCHECK(a.type() == b.type());
GOOGLE_ABSL_DCHECK(a.type() == b.type());
switch (a.type()) {
#define CASE_TYPE(CppType, CamelCppType) \
case FieldDescriptor::CPPTYPE_##CppType: { \
@ -1184,7 +1185,7 @@ class MapKeySorter {
#undef CASE_TYPE
default:
GOOGLE_LOG(DFATAL) << "Invalid key for map field.";
GOOGLE_ABSL_LOG(DFATAL) << "Invalid key for map field.";
return true;
}
}
@ -1326,7 +1327,7 @@ uint8_t* WireFormat::InternalSerializeField(const FieldDescriptor* field,
HANDLE_PRIMITIVE_TYPE(BOOL, bool, Bool, Bool)
#undef HANDLE_PRIMITIVE_TYPE
default:
GOOGLE_LOG(FATAL) << "Invalid descriptor";
GOOGLE_ABSL_LOG(FATAL) << "Invalid descriptor";
}
return target;
}
@ -1542,7 +1543,7 @@ size_t WireFormat::FieldByteSize(const FieldDescriptor* field,
size_t MapKeyDataOnlyByteSize(const FieldDescriptor* field,
const MapKey& value) {
GOOGLE_DCHECK_EQ(FieldDescriptor::TypeToCppType(field->type()), value.type());
GOOGLE_ABSL_DCHECK_EQ(FieldDescriptor::TypeToCppType(field->type()), value.type());
switch (field->type()) {
case FieldDescriptor::TYPE_DOUBLE:
case FieldDescriptor::TYPE_FLOAT:
@ -1550,7 +1551,7 @@ size_t MapKeyDataOnlyByteSize(const FieldDescriptor* field,
case FieldDescriptor::TYPE_MESSAGE:
case FieldDescriptor::TYPE_BYTES:
case FieldDescriptor::TYPE_ENUM:
GOOGLE_LOG(FATAL) << "Unsupported";
GOOGLE_ABSL_LOG(FATAL) << "Unsupported";
return 0;
#define CASE_TYPE(FieldType, CamelFieldType, CamelCppType) \
case FieldDescriptor::TYPE_##FieldType: \
@ -1577,7 +1578,7 @@ size_t MapKeyDataOnlyByteSize(const FieldDescriptor* field,
#undef CASE_TYPE
#undef FIXED_CASE_TYPE
}
GOOGLE_LOG(FATAL) << "Cannot get here";
GOOGLE_ABSL_LOG(FATAL) << "Cannot get here";
return 0;
}
@ -1585,7 +1586,7 @@ static size_t MapValueRefDataOnlyByteSize(const FieldDescriptor* field,
const MapValueConstRef& value) {
switch (field->type()) {
case FieldDescriptor::TYPE_GROUP:
GOOGLE_LOG(FATAL) << "Unsupported";
GOOGLE_ABSL_LOG(FATAL) << "Unsupported";
return 0;
#define CASE_TYPE(FieldType, CamelFieldType, CamelCppType) \
case FieldDescriptor::TYPE_##FieldType: \
@ -1617,7 +1618,7 @@ static size_t MapValueRefDataOnlyByteSize(const FieldDescriptor* field,
#undef CASE_TYPE
#undef FIXED_CASE_TYPE
}
GOOGLE_LOG(FATAL) << "Cannot get here";
GOOGLE_ABSL_LOG(FATAL) << "Cannot get here";
return 0;
}

@ -130,7 +130,7 @@ class PROTOBUF_EXPORT WireFormat {
int expected_endpoint = output->ByteCount() + size;
output->SetCur(
_InternalSerialize(message, output->Cur(), output->EpsCopy()));
GOOGLE_CHECK_EQ(output->ByteCount(), expected_endpoint)
GOOGLE_ABSL_CHECK_EQ(output->ByteCount(), expected_endpoint)
<< ": Protocol message serialized to a size different from what was "
"originally expected. Perhaps it was modified by another thread "
"during serialization?";

@ -39,6 +39,7 @@
#include <string>
#include <vector>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/cord.h"
#include "absl/strings/str_cat.h"
@ -482,7 +483,7 @@ void WireFormatLite::WriteString(int field_number, const std::string& value,
io::CodedOutputStream* output) {
// String is for UTF-8 text only
WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
GOOGLE_CHECK_LE(value.size(), kInt32MaxSize);
GOOGLE_ABSL_CHECK_LE(value.size(), kInt32MaxSize);
output->WriteVarint32(value.size());
output->WriteString(value);
}
@ -491,14 +492,14 @@ void WireFormatLite::WriteStringMaybeAliased(int field_number,
io::CodedOutputStream* output) {
// String is for UTF-8 text only
WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
GOOGLE_CHECK_LE(value.size(), kInt32MaxSize);
GOOGLE_ABSL_CHECK_LE(value.size(), kInt32MaxSize);
output->WriteVarint32(value.size());
output->WriteRawMaybeAliased(value.data(), value.size());
}
void WireFormatLite::WriteBytes(int field_number, const std::string& value,
io::CodedOutputStream* output) {
WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
GOOGLE_CHECK_LE(value.size(), kInt32MaxSize);
GOOGLE_ABSL_CHECK_LE(value.size(), kInt32MaxSize);
output->WriteVarint32(value.size());
output->WriteString(value);
}
@ -506,7 +507,7 @@ void WireFormatLite::WriteBytesMaybeAliased(int field_number,
const std::string& value,
io::CodedOutputStream* output) {
WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
GOOGLE_CHECK_LE(value.size(), kInt32MaxSize);
GOOGLE_ABSL_CHECK_LE(value.size(), kInt32MaxSize);
output->WriteVarint32(value.size());
output->WriteRawMaybeAliased(value.data(), value.size());
}
@ -614,7 +615,7 @@ void PrintUTF8ErrorLog(absl::string_view message_name,
" a protocol buffer. Use the 'bytes' type if you intend to "
"send raw bytes. ",
stacktrace);
GOOGLE_LOG(ERROR) << error_message;
GOOGLE_ABSL_LOG(ERROR) << error_message;
}
bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op,

@ -45,9 +45,9 @@
#include <string>
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/port.h"
#include "absl/base/casts.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/arenastring.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/message_lite.h"
@ -1085,7 +1085,7 @@ template <typename CType, enum WireFormatLite::FieldType DeclaredType>
inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive(
int tag_size, uint32_t tag, io::CodedInputStream* input,
RepeatedField<CType>* values) {
GOOGLE_DCHECK_EQ(UInt32Size(tag), static_cast<size_t>(tag_size));
GOOGLE_ABSL_DCHECK_EQ(UInt32Size(tag), static_cast<size_t>(tag_size));
CType value;
if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;
values->Add(value);
@ -1446,7 +1446,7 @@ inline uint8_t* WireFormatLite::WritePrimitiveNoTagToArray(
const RepeatedField<T>& value, uint8_t* (*Writer)(T, uint8_t*),
uint8_t* target) {
const int n = value.size();
GOOGLE_DCHECK_GT(n, 0);
GOOGLE_ABSL_DCHECK_GT(n, 0);
const T* ii = value.data();
int i = 0;
@ -1465,7 +1465,7 @@ inline uint8_t* WireFormatLite::WriteFixedNoTagToArray(
(void)Writer;
const int n = value.size();
GOOGLE_DCHECK_GT(n, 0);
GOOGLE_ABSL_DCHECK_GT(n, 0);
const T* ii = value.data();
const int bytes = n * static_cast<int>(sizeof(ii[0]));

@ -1230,7 +1230,7 @@ class WireFormatInvalidInputTest : public testing::Test {
const FieldDescriptor* field =
UNITTEST::TestAllTypes::descriptor()->FindFieldByName(
"optional_nested_message");
GOOGLE_CHECK(field != nullptr);
GOOGLE_ABSL_CHECK(field != nullptr);
std::string result;
@ -1252,7 +1252,7 @@ class WireFormatInvalidInputTest : public testing::Test {
bool include_end_tag) {
const FieldDescriptor* field =
UNITTEST::TestAllTypes::descriptor()->FindFieldByName("optionalgroup");
GOOGLE_CHECK(field != nullptr);
GOOGLE_ABSL_CHECK(field != nullptr);
std::string result;

Loading…
Cancel
Save