IWYU, clang-tidy, etc.

PiperOrigin-RevId: 616207739
pull/16181/head
Protobuf Team Bot 9 months ago committed by Copybara-Service
parent c320e11262
commit c6c7d21f6e
  1. 1
      src/google/protobuf/BUILD.bazel
  2. 12
      src/google/protobuf/arena_unittest.cc
  3. 3
      src/google/protobuf/proto3_arena_unittest.cc

@ -1669,6 +1669,7 @@ cc_test(
"//src/google/protobuf/stubs", "//src/google/protobuf/stubs",
"//src/google/protobuf/testing", "//src/google/protobuf/testing",
"//src/google/protobuf/testing:file", "//src/google/protobuf/testing:file",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings", "@com_google_absl//absl/strings",
"@com_google_googletest//:gtest", "@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main", "@com_google_googletest//:gtest_main",

@ -7,13 +7,17 @@
#include "google/protobuf/arena.h" #include "google/protobuf/arena.h"
#include <time.h>
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <atomic> #include <atomic>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <cstdlib>
#include <cstring> #include <cstring>
#include <memory> #include <memory>
#include <new> // IWYU pragma: keep for operator new
#include <string> #include <string>
#include <thread> #include <thread>
#include <type_traits> #include <type_traits>
@ -874,7 +878,7 @@ TEST(ArenaTest, ReleaseFromArenaMessageUsingReflectionMakesCopy) {
const Reflection* r = arena_message->GetReflection(); const Reflection* r = arena_message->GetReflection();
const FieldDescriptor* f = arena_message->GetDescriptor()->FindFieldByName( const FieldDescriptor* f = arena_message->GetDescriptor()->FindFieldByName(
"optional_nested_message"); "optional_nested_message");
nested_msg = static_cast<TestAllTypes::NestedMessage*>( nested_msg = DownCastToGenerated<TestAllTypes::NestedMessage>(
r->ReleaseMessage(arena_message, f)); r->ReleaseMessage(arena_message, f));
} }
EXPECT_EQ(42, nested_msg->bb()); EXPECT_EQ(42, nested_msg->bb());
@ -1482,7 +1486,7 @@ TEST(ArenaTest, MutableMessageReflection) {
const Descriptor* d = message->GetDescriptor(); const Descriptor* d = message->GetDescriptor();
const FieldDescriptor* field = d->FindFieldByName("optional_nested_message"); const FieldDescriptor* field = d->FindFieldByName("optional_nested_message");
TestAllTypes::NestedMessage* submessage = TestAllTypes::NestedMessage* submessage =
static_cast<TestAllTypes::NestedMessage*>( DownCastToGenerated<TestAllTypes::NestedMessage>(
r->MutableMessage(message, field)); r->MutableMessage(message, field));
TestAllTypes::NestedMessage* submessage_expected = TestAllTypes::NestedMessage* submessage_expected =
message->mutable_optional_nested_message(); message->mutable_optional_nested_message();
@ -1492,7 +1496,7 @@ TEST(ArenaTest, MutableMessageReflection) {
const FieldDescriptor* oneof_field = const FieldDescriptor* oneof_field =
d->FindFieldByName("oneof_nested_message"); d->FindFieldByName("oneof_nested_message");
submessage = static_cast<TestAllTypes::NestedMessage*>( submessage = DownCastToGenerated<TestAllTypes::NestedMessage>(
r->MutableMessage(message, oneof_field)); r->MutableMessage(message, oneof_field));
submessage_expected = message->mutable_oneof_nested_message(); submessage_expected = message->mutable_oneof_nested_message();
@ -1655,7 +1659,7 @@ TEST(ArenaTest, Alignment) {
Arena arena; Arena arena;
for (int i = 0; i < 200; i++) { for (int i = 0; i < 200; i++) {
void* p = Arena::CreateArray<char>(&arena, i); void* p = Arena::CreateArray<char>(&arena, i);
ABSL_CHECK_EQ(reinterpret_cast<uintptr_t>(p) % 8, 0) << i << ": " << p; ABSL_CHECK_EQ(reinterpret_cast<uintptr_t>(p) % 8, 0u) << i << ": " << p;
} }
} }

@ -10,9 +10,10 @@
#include <vector> #include <vector>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/absl_check.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "google/protobuf/arena.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/text_format.h"
#include "google/protobuf/unittest.pb.h" #include "google/protobuf/unittest.pb.h"
#include "google/protobuf/unittest_proto3_arena.pb.h" #include "google/protobuf/unittest_proto3_arena.pb.h"

Loading…
Cancel
Save