From 4407d1ed7eb41f31b9315455897921ebea56d811 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 4 Jan 2024 09:53:26 -0800 Subject: [PATCH] IWYU and format fix. PiperOrigin-RevId: 595732256 --- src/google/protobuf/BUILD.bazel | 6 +++ src/google/protobuf/compiler/cpp/BUILD.bazel | 1 + .../compiler/cpp/message_size_unittest.cc | 46 ++++++++++--------- .../generated_message_reflection_unittest.cc | 6 ++- .../generated_message_tctable_lite_test.cc | 9 ++++ 5 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel index d7e6faf28f..aacc707e64 100644 --- a/src/google/protobuf/BUILD.bazel +++ b/src/google/protobuf/BUILD.bazel @@ -1256,7 +1256,9 @@ cc_test( ":test_util", "//src/google/protobuf/stubs", "//src/google/protobuf/testing", + "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:cord", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", @@ -1276,6 +1278,10 @@ cc_test( ":cc_test_protos", ":port", ":protobuf_lite", + "//src/google/protobuf/io", + "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", + "@com_google_absl//absl/strings", "@com_google_absl//absl/types:optional", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", diff --git a/src/google/protobuf/compiler/cpp/BUILD.bazel b/src/google/protobuf/compiler/cpp/BUILD.bazel index 820ec7c0fd..8f87ce26fb 100644 --- a/src/google/protobuf/compiler/cpp/BUILD.bazel +++ b/src/google/protobuf/compiler/cpp/BUILD.bazel @@ -251,6 +251,7 @@ cc_test( "//src/google/protobuf", "//src/google/protobuf:cc_test_protos", "//src/google/protobuf:port", + "//src/google/protobuf:protobuf_lite", "@com_google_absl//absl/log:absl_check", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", diff --git a/src/google/protobuf/compiler/cpp/message_size_unittest.cc b/src/google/protobuf/compiler/cpp/message_size_unittest.cc index 3982a4fd4e..791dbc6df8 100644 --- a/src/google/protobuf/compiler/cpp/message_size_unittest.cc +++ b/src/google/protobuf/compiler/cpp/message_size_unittest.cc @@ -5,10 +5,14 @@ // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd -#include +#include +#include + #include #include "absl/log/absl_check.h" #include "google/protobuf/descriptor.h" +#include "google/protobuf/generated_message_bases.h" +#include "google/protobuf/repeated_ptr_field.h" #include "google/protobuf/unittest.pb.h" // Must be included last. @@ -89,7 +93,7 @@ TEST(GeneratedMessageTest, EmptyMessageWithExtensionsSize) { struct MockGenerated : public MockMessageBase { // 16 bytes MockExtensionSet extensions; // 24 bytes int cached_size; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes of padding }; ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 48); @@ -103,7 +107,7 @@ TEST(GeneratedMessageTest, RecursiveMessageSize) { int cached_size; // 4 bytes void* a; // 8 bytes int32_t i; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes padding }; ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 40); @@ -115,9 +119,9 @@ TEST(GeneratedMessageTest, OneStringSize) { struct MockGenerated : public MockMessageBase { // 16 bytes int has_bits[1]; // 4 bytes int cached_size; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes padding - void* data; // 8 bytes + void* data; // 8 bytes }; ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); EXPECT_EQ(sizeof(protobuf_unittest::OneString), sizeof(MockGenerated)); @@ -126,9 +130,9 @@ TEST(GeneratedMessageTest, OneStringSize) { TEST(GeneratedMessageTest, MoreStringSize) { struct MockGenerated : public MockMessageBase { // 16 bytes int cached_size; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes padding - MockRepeatedPtrField data; // 24 bytes + MockRepeatedPtrField data; // 24 bytes }; ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 48); EXPECT_EQ(sizeof(protobuf_unittest::MoreString), sizeof(MockGenerated)); @@ -138,9 +142,9 @@ TEST(GeneratedMessageTest, Int32MessageSize) { struct MockGenerated : public MockMessageBase { // 16 bytes int has_bits[1]; // 4 bytes int cached_size; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes padding - int32_t data; // 4 bytes + int32_t data; // 4 bytes }; ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); EXPECT_EQ(sizeof(protobuf_unittest::Int32Message), sizeof(MockGenerated)); @@ -150,9 +154,9 @@ TEST(GeneratedMessageTest, Int64MessageSize) { struct MockGenerated : public MockMessageBase { // 16 bytes int has_bits[1]; // 4 bytes int cached_size; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes padding - int64_t data; // 8 bytes + int64_t data; // 8 bytes }; ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); EXPECT_EQ(sizeof(protobuf_unittest::Int64Message), sizeof(MockGenerated)); @@ -162,9 +166,9 @@ TEST(GeneratedMessageTest, BoolMessageSize) { struct MockGenerated : public MockMessageBase { // 16 bytes int has_bits[1]; // 4 bytes int cached_size; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes padding - bool data; // 1 byte + bool data; // 1 byte // + 3 bytes padding }; ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); @@ -175,9 +179,9 @@ TEST(GeneratedMessageTest, OneofSize) { struct MockGenerated : public MockMessageBase { // 16 bytes void* foo; // 8 bytes int cached_size; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes padding - uint32_t oneof_case[1]; // 4 bytes + uint32_t oneof_case[1]; // 4 bytes }; ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 32); EXPECT_EQ(sizeof(protobuf_unittest::TestOneof), sizeof(MockGenerated)); @@ -187,9 +191,9 @@ TEST(GeneratedMessageTest, Oneof2Size) { struct MockGenerated : public MockMessageBase { // 16 bytes int has_bits[1]; // 4 bytes int cached_size; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes padding - void* baz_string; // 8 bytes + void* baz_string; // 8 bytes int32_t baz_int; // 4 bytes // + 4 bytes padding void* foo; // 8 bytes @@ -209,7 +213,7 @@ TEST(GeneratedMessageTest, FieldOrderingsSize) { void* optional_nested_message; // 8 bytes int64_t my_int; // 8 bytes float my_float; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes padding }; ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 80); @@ -221,9 +225,9 @@ TEST(GeneratedMessageTest, TestMessageSize) { struct MockGenerated : public MockMessageBase { // 16 bytes int has_bits[1]; // 4 bytes int cached_size; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes padding - void* m4; // 8 bytes + void* m4; // 8 bytes int64_t m2; // 8 bytes bool m1; // 1 bytes bool m3; // 1 bytes @@ -259,7 +263,7 @@ TEST(GeneratedMessageTest, PackedTypesSize) { MockRepeatedField packed_enum; // 16 bytes int packed_enum_cached_byte_size; // 4 bytes int cached_size; // 4 bytes - PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes + PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes // + 0-4 bytes padding }; ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 16 * 15 + 8 * 6 + 8); diff --git a/src/google/protobuf/generated_message_reflection_unittest.cc b/src/google/protobuf/generated_message_reflection_unittest.cc index 93bfcbbee3..4925f53ada 100644 --- a/src/google/protobuf/generated_message_reflection_unittest.cc +++ b/src/google/protobuf/generated_message_reflection_unittest.cc @@ -22,16 +22,20 @@ #include "google/protobuf/generated_message_reflection.h" #include +#include +#include #include -#include "google/protobuf/testing/googletest.h" #include +#include "absl/flags/flag.h" #include "absl/log/absl_check.h" #include "absl/strings/cord.h" +#include "absl/strings/string_view.h" #include "google/protobuf/arena.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/map_test_util.h" #include "google/protobuf/map_unittest.pb.h" +#include "google/protobuf/message.h" #include "google/protobuf/test_util.h" #include "google/protobuf/unittest.pb.h" #include "google/protobuf/unittest.pb.h" diff --git a/src/google/protobuf/generated_message_tctable_lite_test.cc b/src/google/protobuf/generated_message_tctable_lite_test.cc index 136fea52a8..719e5202f8 100644 --- a/src/google/protobuf/generated_message_tctable_lite_test.cc +++ b/src/google/protobuf/generated_message_tctable_lite_test.cc @@ -6,11 +6,20 @@ // https://developers.google.com/open-source/licenses/bsd #include +#include +#include #include #include +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include "google/protobuf/generated_message_tctable_decl.h" #include "google/protobuf/generated_message_tctable_impl.h" +#include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/parse_context.h" #include "google/protobuf/unittest.pb.h" #include "google/protobuf/wire_format_lite.h"