diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel index a1c9c0b5b7..5acd54c5ea 100644 --- a/src/google/protobuf/BUILD.bazel +++ b/src/google/protobuf/BUILD.bazel @@ -1669,6 +1669,7 @@ cc_test( "//src/google/protobuf/stubs", "//src/google/protobuf/testing", "//src/google/protobuf/testing:file", + "@com_google_absl//absl/log:absl_check", "@com_google_absl//absl/strings", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc index 7e2f0ad75a..8c961b4dd9 100644 --- a/src/google/protobuf/arena_unittest.cc +++ b/src/google/protobuf/arena_unittest.cc @@ -7,13 +7,17 @@ #include "google/protobuf/arena.h" +#include + #include #include #include #include #include +#include #include #include +#include // IWYU pragma: keep for operator new #include #include #include @@ -874,7 +878,7 @@ TEST(ArenaTest, ReleaseFromArenaMessageUsingReflectionMakesCopy) { const Reflection* r = arena_message->GetReflection(); const FieldDescriptor* f = arena_message->GetDescriptor()->FindFieldByName( "optional_nested_message"); - nested_msg = static_cast( + nested_msg = DownCastToGenerated( r->ReleaseMessage(arena_message, f)); } EXPECT_EQ(42, nested_msg->bb()); @@ -1482,7 +1486,7 @@ TEST(ArenaTest, MutableMessageReflection) { const Descriptor* d = message->GetDescriptor(); const FieldDescriptor* field = d->FindFieldByName("optional_nested_message"); TestAllTypes::NestedMessage* submessage = - static_cast( + DownCastToGenerated( r->MutableMessage(message, field)); TestAllTypes::NestedMessage* submessage_expected = message->mutable_optional_nested_message(); @@ -1492,7 +1496,7 @@ TEST(ArenaTest, MutableMessageReflection) { const FieldDescriptor* oneof_field = d->FindFieldByName("oneof_nested_message"); - submessage = static_cast( + submessage = DownCastToGenerated( r->MutableMessage(message, oneof_field)); submessage_expected = message->mutable_oneof_nested_message(); @@ -1655,7 +1659,7 @@ TEST(ArenaTest, Alignment) { Arena arena; for (int i = 0; i < 200; i++) { void* p = Arena::CreateArray(&arena, i); - ABSL_CHECK_EQ(reinterpret_cast(p) % 8, 0) << i << ": " << p; + ABSL_CHECK_EQ(reinterpret_cast(p) % 8, 0u) << i << ": " << p; } } diff --git a/src/google/protobuf/proto3_arena_unittest.cc b/src/google/protobuf/proto3_arena_unittest.cc index f8c0070b02..38f4df098e 100644 --- a/src/google/protobuf/proto3_arena_unittest.cc +++ b/src/google/protobuf/proto3_arena_unittest.cc @@ -10,9 +10,10 @@ #include #include +#include "absl/log/absl_check.h" #include "absl/strings/match.h" #include "google/protobuf/arena.h" -#include "google/protobuf/test_util.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/text_format.h" #include "google/protobuf/unittest.pb.h" #include "google/protobuf/unittest_proto3_arena.pb.h"